Last active
August 29, 2015 14:23
-
-
Save dommmel/448b91838f501d306deb to your computer and use it in GitHub Desktop.
Unbounce Cross Domain External Tracking
This file contains 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
// On external pages (same domain) you need to grab the cookie | |
function getCookie(name) { | |
var value = "; " + document.cookie; | |
var parts = value.split("; " + name + "="); | |
if (parts.length == 2) return parts.pop().split(";").shift(); | |
} | |
var url = "http://t.unbounce.com/trk?v=" + getCookie('ubvt') + "&g=convert" | |
// On the unbounce page itself you have direct access | |
var url = "http://t.unbounce.com/trk?v=" + ub.page.visitorId + "&g=convert" | |
/* | |
To track a conversion from anywhere you need to send a GET request to the url you generate above. | |
If you do this server side you need to set a UserAgent | |
$ curl -A "UserAgentString" "http://t.unbounce.com/trk?v=212.62.201.2481435531293450082&g=convert" | |
In the browser you can issue the GET request like this: | |
<script> | |
var script = document.createElement("script"); | |
script.src=url; | |
script.type="text/javascript"; | |
script.async=true; | |
document.body.appendChild(script); | |
</script> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment