Integration via tracking codes for Shopify

If your website was created on the Shopify platform, you can quickly integrate it with the Admitad 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. The tracking code has to be placed on your website, which will then be integrated with the Admitad system.

General information: specifics and tips

  • You can only initiate integration if your program has:
    • A tracking link generated in General Settings.
    • A target action added and a related rate set up in Actions.

If you don't have a manager, you'll need to generate a tracking link on your own (see this guide) and add at least one action and at least one rate (see this guide).
If you have a personal manager, they will do this for you.

  • Integration is a mandatory step to continuing your work and starting an affiliate program with Admitad.
  • If you run into any problems during integration, ask your technical specialist for help. Show them this guide and ask your questions.

Once integration is complete, all target action details (date, order ID, order amount, etc.) will be sent to Admitad automatically.

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;ao.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()
    {++to.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>

6. Replace the {your_campaign_code} value with the campaign_code value and click Save.
You will get the parameter that looks as follows: campaign_code=a1b2c3d4e5, where the highlighted part is the unique number of your affiliate program. Where to get the campaign_code value

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">
       ADMITAD = window.ADMITAD || {};
       ADMITAD.Invoice = ADMITAD.Invoice || {};
    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 the values of {your_action_code}, {your_tariff_code}, and {your_campaign_code} with the values of action_code, tariff_code, and campaign_code, respectively. Where to get the values of these parameters
Click Save at the bottom of the page.

You're all done! The tracking code has been installed and configured.

How deduplication in the tracking code on the Shopify platform works

Deduplication is a data processing method that helps identify a paid traffic source to attribute an order to it and remove duplicate target actions, if any.

  • Paid traffic sources are third-party resources that you pay to attract customers on certain terms (e.g., you pay for a visit to your website, ad view, application, registration, or purchase). Cooperation models also include targeted advertising, contextual advertising, sponsored posts on influencers' channels, etc.

The deduplication is already set up in the tracking code.
So target action data is passed to Admitad per the Last Paid Click attribution model. If a publisher with Admitad was the last paid traffic source, that action should be attributed to Admitad.

The deduplication cookie with a paid source value is generated automatically in the tracking code that you place on all pages of your website.

When a user places an order on your site, the tracking code automatically determines the last source by the value of the utm_source parameter.

The value utm_source=admitad in the last link the user followed means that the target action will be attributed to Admitad.

For deduplication to work correctly, each paid traffic source must have utm_source in the transition link with its own unique value.

To set up custom deduplication (for example: set your own value names or change cookie lifetime):

Place the deduplication code on all pages of the site after the tracking code.

  • <script type="text/javascript">
    // name of the cookie that stores the source
    // change if you have another name
    var cookie_name = 'deduplication_cookie';
    // cookie lifetime
    var days_to_store = 90;
    // expected deduplication_cookie value for Admitad
    var deduplication_cookie_value = 'admitad';
    // name of GET parameter for deduplication
    // change if you have another name
    var channel_name = 'utm_source';
    // a function to get the source from the GET parameter
    getSourceParamFromUri = function () {
      var pattern = channel_name + '=([^&]+)';
      var re = new RegExp(pattern);
      return (re.exec(document.location.search) || [])[1] || '';
    };
    // a function to get the source from the cookie named cookie_name
    getSourceCookie = function () {
      var matches = document.cookie.match(new RegExp(
        '(?:^|; )' + cookie_name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + '=([^;]*)'
      ));
      return matches ? decodeURIComponent(matches[1]) : undefined;
    };
    // a function to set the source in the cookie named cookie_name
    setSourceCookie = function () {
      var param = getSourceParamFromUri();
      var params = (new URL(document.location)).searchParams;
      if (!params.get(channel_name) && params.get('gclid')) { param = 'advAutoMarkup' }
      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;
    };
    // set cookie
    setSourceCookie();
    </script>

To correctly identify the traffic source on the “Thank You” page, place the code below right after the tracking code.

  • This code will have a higher priority than the deduplication code built into the tracking code.

    <script>
    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';
    }
    </script>

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 (Program → Integration).

    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.

FAQ

Where do I find the campaign_code value?

1. In your account, go to the Integration section (Program → Integration).

2. Click Next and, on the Integration methods page, open the Integration via plugin tab.

3. In the Integration via plugin tab, select Shopify and click Next.

4. Find the campaign_code value in the table located at the top part of the screen (Integration setup: unique parameter values for your program).

Get back to installing and configuring the tracking code

Where do I find the action_code value?

1. In your account, go to the Integration section (Program → Integration).

2. Click Next and, on the Integration methods page, open the Integration via plugin tab.

3. In the Integration via plugin tab, select Shopify and click Next.

4. In the Action column of the second table, find the action whose code you need.
You will find the action_code value in this action's row in the Action code column (Integration setup: unique parameter values for your program).

Go back to installing and configuring the tracking code

Where do I find the tariff_code value?

1. In your account, go to the Integration section (Program → Integration).

2. Click Next and, on the Integration methods page, open the Integration via plugin tab.

3. In the Integration via plugin tab, select Shopify and click Next.

4. In the Rate column of the second table, find the rate whose code you need.
You will find the tariff_code value in this rate's row in the Rate code column (Integration setup: unique parameter values for your program).

Go back to installing and configuring the tracking code

Is this article helpful?
0 0 0