When the Convert cookie data cannot be transferred to the purchase confirmation page on another domain

Issue

There are some systems that do not allow to pass any data via query parameters to the purchase confirmation page or checkout funnel. This prevents Convert from attributing the conversion to the variation that the visitor saw and registering the conversion.

Solution

There is a solution for this, in which the purchase confirmation can call back the first domain and issue the conversion from that domain, being able to read the experiment and variation data and send it to Convert servers to display it on your reports.

We will provide an example with code on how to do this

  1. First, insert a small javascript snippet on the purchase confirmation page. This snippet has variables that should be mapped to your checkout system revenue and product count ones.
    // Map this to your own checkout variables:
    convert_amount = your_own_system_amount;
    convert_count = your_own_system_product_count;

    var newFrame = document.createElement("frame");
    newFrame.id = "pushRevenueframe";
    newFrame.name = "pushRevenueframe";
    newFrame.src = 'http://firstdomain.com/convertrevenue.html?amount=' + convert_amount + '&product_count=' + convert_count;
    var m = document.querySelectorAll('body');
    m[0].appendChild(newFrame).style = 'width:0; height:0; border:0; border:none';
  2. Create a small HTML file with the following code upload it to your first domain server, containing the following:
    <html>
    <head>
    // Replace the following with your own snippet
    <!-- begin Convert Experiences code-->
    <script type="text/javascript" src="//cdn-3.convertexperiments.com/js/10000001-10000002.js"></script>
    <!-- end Convert Experiences code -->
    </head>
    <body>
    <script>
    _conv_q = window._conv_q || [];
    _conv_q.push(["pushRevenue",convert.getUrlParameter('amount'),convert.getUrlParameter('product_count'), "1231456789"]);
    </script>
    </body>
    </html>
    Make sure you change the snippet to correspond to your own Project Snippet and replace the 123456789 with the id of your own Revenue goal.

    Once done, the first script should call your HTML file, and the HTML file will relay the revenue back to Convert. 

Upsell Tracking on Shopify (Carthook and other upsell solutions)

On Shopify you can add similar code than the snippet mentioned above. The code should be added on the new Post Purchase > Additional Scripts section. However, this setup is required as from the contained code execution environment the Convert cookies cannot be accessed, and therefore the file on the primary site also needs to be added as a page created on Shopify.

Post Purchase > Additional Scripts code:

{% assign products_count = 0 %}
{% for line_item in line_items %}
{% capture products_count %}{{ products_count | plus: line_item.quantity }}{% endcapture %}
{% endfor %}
{% if first_time_accessed %}
<script type="text/javascript">
convert_amount = {{ subtotal_price | money_without_currency }};
convert_count = {{ products_count }};

var newFrame = document.createElement("frame");
newFrame.id = "pushRevenueframe";
newFrame.name = "pushRevenueframe";
newFrame.src = 'http://firstdomain.com/convertrevenue.html?amount=' + convert_amount + '&product_count=' + convert_count;
var m = document.querySelectorAll('body');
m[0].appendChild(newFrame).style = 'width:0; height:0; border:0; border:none';
</script>
{% endif %}

Code for new page on Shopify: Add the following code while editing it.

// If your convert tracking code is not included on the template page, then you need to add it here.
<script>
window.addEventListener('DOMContentLoaded', (event) => {
var amount = convert.getUrlParameter('amount');
var product_count = convert.getUrlParameter('product_count');
if (amount && product_count) {
window._conv_q = window._conv_q || [];
// Change 123456789 to your own revenue goal id
window._conv_q.push(["pushRevenue",amount,product_count, "1231456789"]);
}
});
</script>

Chimpuppystore___Revenue_tracking___Shopify.png

Need assistance? Start a conversation with our Support Team.
CONVERT MORE

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments