Integration via tracking codes for Shopify

  • Updated

If your website was created on the Shopify platform, you can quickly integrate it with the Admitad Partner Network using a tracking code.

A tracking code is a JavaScript code that allows target actions to be registered and information about them to be transmitted to the Admitad Partner Network. The tracking code has to be placed on your website, which will then be integrated with the Admitad system.

How to place the tracking code on the website and configure it

Before setting up the integration, request the value of the parameters {your_action_code}, {your_tariff_code} and {your_campaign_code} for your store from the Admitad tracking department specialist.

If your program has more than one action and rate, report this to the Admitad specialist. You'll receive additional information about setting up the integration.


1. Open https://www.shopify.com/ and log in to your account. Your website's admin panel will open.

2. Go to the Themes section (Online Store → Themes).

unnamed-1.png

3. In the Current theme block in the website theme, open the Actions list (1) and select Edit code (2).

unnamed-2.png

4. On the page that opens, select the theme.liquid file on the panel to the left. A file with the source code will open.

5. Copy the code below and insert it into your website's source code before the closing tag </head>.

  • <script src="https://www.artfut.com/static/tagtag.min.js?campaign_code={your_campaign_code}" onerror='var self = this;window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers=ADMITAD.Helpers||{},ADMITAD.Helpers.generateDomains=function(){for(var e=new Date,n=Math.floor(new Date(2020,e.getMonth(),e.getDate()).setUTCHours(0,0,0,0)/1e3),t=parseInt(1e12*(Math.sin(n)+1)).toString(30),i=["de"],o=[],a=0;a<i.length;++a)o.push({domain:t+"."+i[a],name:t});return o},ADMITAD.Helpers.findTodaysDomain=function(e){function n(){var o=new XMLHttpRequest,a=i[t].domain,D="https://"+a+"/";o.open("HEAD",D,!0),o.onload=function(){setTimeout(e,0,i[t])},o.onerror=function(){++t<i.length?setTimeout(n,0):setTimeout(e,0,void 0)},o.send()}var t=0,i=ADMITAD.Helpers.generateDomains();n()},window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers.findTodaysDomain(function(e){if(window.ADMITAD.dynamic=e,window.ADMITAD.dynamic){var n=function(){return function(){return self.src?self:""}}(),t=n(),i=(/campaign_code=([^&]+)/.exec(t.src)||[])[1]||"";t.parentNode.removeChild(t);var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.src="https://www."+window.ADMITAD.dynamic.domain+"/static/"+window.ADMITAD.dynamic.name.slice(1)+window.ADMITAD.dynamic.name.slice(0,1)+".min.js?campaign_code="+i,o.appendChild(a)}});'></script>
    <script type="text/javascript">
    var cookie_name = 'deduplication_cookie';
    var days_to_store = 90;
    var deduplication_cookie_value = 'admitad';
    var channel_name = 'utm_source';
    getSourceParamFromUri = function () {
     var pattern = channel_name + '=([^&]+)';
     var re = new RegExp(pattern);
     return (re.exec(document.location.search) || [])[1] || '';
    };
    getSourceCookie = function () {
     var matches = document.cookie.match(new RegExp(
       '(?:^|; )' + cookie_name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + '=([^;]*)'
     ));
     return matches ? decodeURIComponent(matches[1]) : undefined;
    };
    setSourceCookie = function () {
     var param = getSourceParamFromUri();
     var params = (new URL(document.location)).searchParams;
     if (!params.get(channel_name) && params.get('gclid')) { param = 'google' }
     else if (!params.get(channel_name) && params.get('fbclid')) { param = 'facebook' }
     else if (!param) { return; }
     var period = days_to_store * 60 * 60 * 24 * 1000; // in seconds
     var expiresDate = new Date((period) + +new Date);
     var cookieString = cookie_name + '=' + param + '; path=/; expires=' + expiresDate.toGMTString();
     document.cookie = cookieString;
     document.cookie = cookieString + '; domain=.' + location.host;
    };
    setSourceCookie();
    </script>
    

6. Replace {your_campaign_code} with the value sent to you by the tracking department specialist. Click Save.

7. Click Exit to return to the previous page, then go to Settings.

unnamed-3.png

8. In the Settings modal window, click Checkout.

unnamed-4.png

9. Scroll down the page and find the Order status page block. In the Additional scripts field, add the following code:

  • <script src="https://www.artfut.com/static/tagtag.min.js?campaign_code={your_campaign_code}" onerror='var self = this;window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers=ADMITAD.Helpers||{},ADMITAD.Helpers.generateDomains=function(){for(var e=new Date,n=Math.floor(new Date(2020,e.getMonth(),e.getDate()).setUTCHours(0,0,0,0)/1e3),t=parseInt(1e12*(Math.sin(n)+1)).toString(30),i=["de"],o=[],a=0;a<i.length;++a)o.push({domain:t+"."+i[a],name:t});return o},ADMITAD.Helpers.findTodaysDomain=function(e){function n(){var o=new XMLHttpRequest,a=i[t].domain,D="https://"+a+"/";o.open("HEAD",D,!0),o.onload=function(){setTimeout(e,0,i[t])},o.onerror=function(){++t<i.length?setTimeout(n,0):setTimeout(e,0,void 0)},o.send()}var t=0,i=ADMITAD.Helpers.generateDomains();n()},window.ADMITAD=window.ADMITAD||{},ADMITAD.Helpers.findTodaysDomain(function(e){if(window.ADMITAD.dynamic=e,window.ADMITAD.dynamic){var n=function(){return function(){return self.src?self:""}}(),t=n(),i=(/campaign_code=([^&]+)/.exec(t.src)||[])[1]||"";t.parentNode.removeChild(t);var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.src="https://www."+window.ADMITAD.dynamic.domain+"/static/"+window.ADMITAD.dynamic.name.slice(1)+window.ADMITAD.dynamic.name.slice(0,1)+".min.js?campaign_code="+i,o.appendChild(a)}});'></script>
    <script type="text/javascript">
    var cookie_name = 'deduplication_cookie';
    var days_to_store = 90;
    var deduplication_cookie_value = 'admitad';
    var channel_name = 'utm_source';
    getSourceParamFromUri = function () {
     var pattern = channel_name + '=([^&]+)';
     var re = new RegExp(pattern);
     return (re.exec(document.location.search) || [])[1] || '';
    };
    getSourceCookie = function () {
     var matches = document.cookie.match(new RegExp(
       '(?:^|; )' + cookie_name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + '=([^;]*)'
     ));
     return matches ? decodeURIComponent(matches[1]) : undefined;
    };
    setSourceCookie = function () {
     var param = getSourceParamFromUri();
     var params = (new URL(document.location)).searchParams;
     if (!params.get(channel_name) && params.get('gclid')) { param = 'google' }
     else if (!params.get(channel_name) && params.get('fbclid')) { param = 'facebook' }
     else if (!param) { return; }
     var period = days_to_store * 60 * 60 * 24 * 1000; // in seconds
     var expiresDate = new Date((period) + +new Date);
     var cookieString = cookie_name + '=' + param + '; path=/; expires=' + expiresDate.toGMTString();
     document.cookie = cookieString;
     document.cookie = cookieString + '; domain=.' + location.host;
    };
    setSourceCookie();
    </script>
    <script type="text/javascript">
       ADMITAD = window.ADMITAD || {};
       ADMITAD.Invoice = ADMITAD.Invoice || {};
    if (!getSourceCookie(cookie_name)) {
    ADMITAD.Invoice.broker = 'na';
    } else if (getSourceCookie(cookie_name) != deduplication_cookie_value) {
    ADMITAD.Invoice.broker = getSourceCookie(cookie_name);
    } else {
    ADMITAD.Invoice.broker = 'adm';
    } ADMITAD.Invoice.category = '{your_action_code}'; // action code (defined during integration) var orderedItem = []; // temporary array for product items var coup = ''; var targ = ''; {% for discount_application in discount_applications %} coup = '{{ discount_application.title }}'; targ = '{{ discount_application.target_type }}'; {% endfor %} var disc = ( targ != 'shipping_line' && '{{ discounts_amount | divided_by: 100.00 }}' > 0 ) ? Number({{ discounts_amount | divided_by: 100.00 }}) : '0'; disc = Number(disc + {{ gift_cards_amount | divided_by: 100.00 }}); var total = Number(({{ subtotal_price | divided_by: 100.00 }} - {{ gift_cards_amount | divided_by: 100.00 }}) + disc); //order price without discount // if there is a discount, we calculate the discount percentage and get the name of coupon var average_price = (disc > 0) ? Number((total - disc) / total) : '1'; {% for item in checkout.line_items %} var price = '{{ item.price | divided_by: 100.00 }}'; // repeat for every product item in the cart orderedItem.push({ Product: { productID: '{{ item.product_id }}', category: '{your_tariff_code}', price: (price*average_price).toFixed(3), // apply a discount to the product price priceCurrency: '{{ currency }}', // currency }, orderQuantity: '{{ item.quantity }}', additionalType: "sale" // payment_type }); {% endfor %} ADMITAD.Invoice.referencesOrder = ADMITAD.Invoice.referencesOrder || []; // adding items to the order ADMITAD.Invoice.referencesOrder.push({ orderNumber: '{{ checkout.order_id }}', discountCode: coup, // promocode orderedItem: orderedItem }); // Important! If order data is loaded via AJAX, uncomment this string. // ADMITAD.Tracking.processPositions(); </script>

10. Replace {your_action_code}, {your_tariff_code} and {your_campaign_code} with the values sent to you by the tracking department specialist.
At the bottom of the page, click Save.

You're good to go! The tracking code has been installed and configured.

How to set up deduplication

If you work only with the Admitad Partner Network, leave the default value for the deduplication parameter and go to the testing the configured integration section.

If you work with several paid traffic sources simultaneously, you have to configure deduplication.
This will allow orders to be properly attributed to the respective sources and eliminate duplicate target actions, if any are present.

When deduplication is configured, information on the action is transmitted to Admitad according to the Last Paid Click attribution model. In other words, if the last paid source was the Admitad Partner Network publisher, then the action must be attributed to Admitad.


To set up deduplication:

1. Tell the Admitad Partner Network specialist what GET parameter from the website's login page you will be using for deduplication.
The parameter isn't added by default.

2. Create a deduplication cookie with the source value. The cookie must be saved throughout the entire period specified in the offer or agreement; it's 90 days by default.

3. Specify the deduplication parameter value from the cookie when transmitting data on the action in the ADMITAD.Invoice.broker parameter.

The deduplication parameter value determines the source of the target action.

For actions that must be attributed to Admitad, specify the following deduplication parameter value: adm.


Done! Deduplication of actions has been configured.

Actions with values of other paid sources won't be recorded in the Admitad reports.
Actions with an unspecified source will be created if another device or browser of this user had a transition to the website via the Admitad publisher during the cookie's lifetime.

 

How to test integration after setup

1. Get a test affiliate link on the Setting up integration for Shopify page in the Integration testing section.

  • 1.1 In your account, go to the Integration section (menuProgramIntegration).

    1.2 Click Next, and on the Integration methods page, select Shopify. Click Next.

    1.3 The Integration testing section is located on the bottom part of the screen.

2. Click the link and complete the target action according to the terms of your program.

Recommendations for integration testing:

  • Perform several test orders to check all the actions and rates.

  • Include several items in one of your test orders to make sure the items and the total amount are transmitted correctly.

  • If you have a quick order or one-click order form, use it to place an order and test the form integration.

The test order will appear in Admitad statistics within an hour.

If the order doesn't show up in reports after an hour or more, make sure the integration was set up correctly (see instructions). If the problem persists, report it to the Admitad specialist.


3. Go to your personal account in Admitad → Reports → On actions, and check that the report correctly shows the target actions and data on it:

  • The target action corresponds to the partner program settings.
  • The order ID in Admitad corresponds to the order ID in your system.
  • The order amount in Admitad corresponds to the test order amount.

4. Tell the Admitad Partner Network specialist that testing is complete. The program will then be prepared for launch.

All done. Integration testing is complete.

 

How to delete the tracking code from your website

1. In your website's admin panel, open the theme.liquid file and follow steps 1–3 from this guide.

2. Delete the Admitad code that was added before the closing tag </head>.
Click Save.

3. Click Exit to return to the previous page.

4. Click Settings on the page that opens. The Settings modal window will open.

5. Click Checkout in the Settings modal window.

6. Scroll down the page and find the Order status page block.
Delete the Admitad code in the Additional scripts field. Click Save at the bottom of the page.


Done. The tracking code has been deleted.

Was this article helpful?