Created
June 11, 2016 07:44
-
-
Save flowtwo/86ec9de27316151680483d646398110c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="fund" class="fund"></div> | |
<script type="text/javascript"> | |
var s = document.createElement('script'); | |
s.type = 'text/javascript'; | |
s.async = true; | |
s.src = "https://onlinefundraising.dk/js/3.5/iframe.js"; | |
var x = document.getElementsByTagName('script')[0]; | |
x.parentNode.insertBefore(s, x); | |
function OFfit() { | |
if (window.iFrameResize) { | |
iFrameResize({ | |
enablePublicMethods: true, | |
checkOrigin: false | |
}); | |
} | |
} | |
function OF() { | |
var a = 'pre_device=' + window.innerWidth, | |
b = window.location.search.substring(1), | |
d = ''; | |
if (b) { | |
if (b !== 'undefined') { | |
d = "&" + b; | |
} | |
} | |
var uri = "http://of.devflowtwo.com/chr/?" + a + d, | |
src = uri.replace(/amp;/g, "").replace(/#038;/g, ""), | |
iframe = document.createElement('iframe'); | |
iframe.width = "100%"; | |
iframe.scrolling = "no"; | |
iframe.setAttribute("src", src); | |
iframe.setAttribute("frameBorder", "0"); | |
document.getElementById('fund').appendChild(iframe); | |
OFfit(); | |
} | |
if (window.addEventListener) { | |
window.addEventListener("load", OF, false); | |
} else if (window.attachEvent) { | |
window.attachEvent("onload", OF); | |
} else { | |
window.onload = OF; | |
} | |
function OF_setCookie(cname, cvalue, exdays) { | |
var d = new Date(); | |
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); | |
var expires = "expires=" + d.toUTCString(); | |
document.cookie = cname + "=" + cvalue + "; " + expires; | |
} | |
function OF_getCookie(cname) { | |
var name = cname + "="; | |
var ca = document.cookie.split(';'); | |
for (var i = 0; i < ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0) === ' ') { | |
c = c.substring(1); | |
} | |
if (c.indexOf(name) === 0) { | |
return c.substring(name.length, c.length); | |
} | |
} | |
return ""; | |
} | |
function OF_hasCookie(cname) { | |
var name = cname + "="; | |
var ca = document.cookie.split(';'); | |
for (var i = 0; i < ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0) === ' ') { | |
c = c.substring(1); | |
} | |
if (c.indexOf(name) === 0) { | |
return true; | |
} | |
} | |
return false; | |
} | |
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m); | |
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | |
function OF_sendTrack(obj) { | |
ga('create', 'UA-50839665-7', 'auto'); | |
ga('send', 'pageview'); | |
ga('require', 'ecommerce'); | |
ga('ecommerce:addTransaction', { | |
'id': '' + obj['postid'], | |
'affiliation': obj['affiliation'], | |
'revenue': '' + obj['amount'] | |
}); | |
ga('ecommerce:addItem', { | |
'id': '' + obj['postid'], | |
'name': '' + obj['project_name'], | |
'category': '' + obj['category'], | |
'price': '' + obj['amount'], | |
'quantity': '1' | |
}); | |
ga('ecommerce:send'); | |
} | |
var url = location.search; | |
var result = ''; | |
var sURLvar = url.split(String.fromCharCode(38)); | |
for (var i = 0; i < sURLvar.length; i++) { | |
var sParName = sURLvar[i].split('='); | |
if (sParName[0] === 'tp') { | |
var result = sParName[1]; | |
} | |
} | |
if (result) { | |
var obj = JSON.parse(atob(result)); | |
var postCookie = 'has_sent_' + obj['postid']; | |
if (!OF_hasCookie(postCookie)) { | |
OF_setCookie(postCookie, 'sent', 10000); | |
OF_sendTrack(obj); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment