Skip to content

Instantly share code, notes, and snippets.

@dommmel
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dommmel/448b91838f501d306deb to your computer and use it in GitHub Desktop.
Save dommmel/448b91838f501d306deb to your computer and use it in GitHub Desktop.
Unbounce Cross Domain External Tracking
// 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