How to track a cross-domain Sale/custom goal?
Browser security rules make tracking goals on cross domains a little tricky for every client-side application, and some custom integration is necessary.
The only goal type that can be measured on cross domains is the ‘custom’ one.
Let’s say you have two different domains – domain-one.com and domain-two.com, and you want to set an experiment on domain-one.com which sends the visitors to domain-two.com, and you want to track how many of them convert on domain-two.com.
Well in order to do that, on the domain-two.com page, on which you want to track conversions ( for example, domain-two.com/thank-you.html ) , you must insert an iframe, in the body of the thank you page, that contains a link to a custom page (conversion.html) hosted on the original domain/website which in this case is domain-one.com.
The iframe script that must be inserted is the following:
The conversion.html page is a stand-alone HTML page, hosted on the domain-one.com that should contain the following code:
If you need to save a goal value you can pass it via a GET parameter to this iframe. In this case, the URL should look like this: http://domain-one.com/conversion.html?sale=[value]
Also, the iframe code has to be modified to handle the new parameter:
<script> var urlParams = new URLSearchParams(window.location.search); var saleValue = urlParams.get(“sale”); var _mktz = _mktz || ; _mktz.push(['_Goal','Sale',saleValue]); //insert the goal code generated by Omniconvert </script>
Attention: This code must be installed only on the page where you want to track the goal – Eg: the thank you page – NOT on the pages where the experiments are running. Installing it on the pages where experiments are active will stop them from working!