Skip to main content
Code-based Shopify Integration

Looking to place Tapfiliate in more than one Shopify store? That's possible with our code-based integration!

Sonya avatar
Written by Sonya
Updated this week

Tapfiliate's recently released Shopify integration is a huge step up from our previous integration option. However (and due to Shopify's current limitations), Tapfiliate's plug-and-play integration option means you connect one Shopify store per one Tapfiliate account.

This is why we're keeping our old integration option available to you.

It's an easy-to-install, code-based integration that you can install in each Shopify store you'd like to track in.

Code-based integration for Shopify

Rather follow a step-by-step guide? Here are the steps towards installing Tapfiliate code into your Shopify store

1. In your shop’s admin environment, please go to: Log in to your shop > Open Setting > Click on Customer events > Add custom pixel > Name the pixel and press Add pixel.

  1. Permissions: Choose Required > Check the boxes next to Marketing and Analytics.

  2. Data sale: Please, choose Data collected does not qualify as data sale.

  3. Next, in the Code section, paste the following code:

window.self = window.top; 

const script = document.createElement('script');
script.setAttribute('src', 'https://script.tapfiliate.com/tapfiliate.js'); script.setAttribute('async', ''); document.head.appendChild(script);

(function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){ (t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

tap('create', 'YOUR ACCOUNT ID', { integration: "shopify" }); tap('detect');

analytics.subscribe('checkout_completed', (event) => {
const checkout = event.data.checkout;
const order_currency = checkout.totalPrice.currencyCode;
const order_price = checkout.subtotalPrice.amount const order_id = checkout.order.id;
const email = checkout.email; const discount_codes = checkout.discountApplications.map((discount) => {
if (discount.type === 'DISCOUNT_CODE') {
return discount.title;
}
});

tap('conversion', order_id, order_price, {
coupons: discount_codes,
currency: order_currency,
customer_id: email,
});
});

Make sure to replace YOUR ACCOUNT ID with your actual account id.

4. Hit save > Press Connect, and you are all done!

5. Test your integration. You can do this by adding ?tap_test=true to the end of your store's landing page URL. This will prompt our integration tester to appear. If you see it, complete a test purchase to confirm that your integration is working.

FAQ

Does this code track refunds and order cancelations?

These scripts will only track clicks and conversions. Anything that happens after checkout (refunds, order cancelations, etc.) will not be picked up by this code-based integration.

However, you or a developer could definitely set up the logic to support this on your end. Our "Create deeper integrations" article lists which endpoints to use for each process.

Is cross-domain tracking supported?

No, cross-domain tracking is not supported. Tapfiliate's software works with first-party cookies, which only work for the domain in which they are initially sorted. These cookies cannot be tracked across different domains. For more information, check out our How tracking works article.

How do I track multiple commission types/SKUs within this integration?

It is now possible to distinguish different commission types in your store when sending the conversion data. To proceed, you have to adjust your code in the Code section as follows:

  1. Create the identifiers for extra commission types in your Tapfiliate account by following our guide.

  2. In your Shopify tracking code you've added to the Code section, add the following object: COMMISSION-TYPE-IDENTIFIER as in the example below:

tap('conversion', order_id, order_price, COMMISSION-TYPE-IDENTIFIER, {

coupons: discount_codes,

currency: order_currency,

customer_id: email,

});

Don't forget to replace YOUR ACCOUNT ID with your actual Tapfiliate account ID.

What happens if I install both the code-based integration and the plug-in at the same time in the same store?

If you have both the code-based integration and the plug-in installed, this is what will happen:

  • Clicks will track twice. This is because you will have two click-tracking scripts installed in your store.

  • Conversions will track only once. We perform de-duplication based on the external_id value (in Shopify's case, the order number). This means we'd only track once per transaction, and you do not have to worry about duplicates.

I would like to use the new Shopify integration. How do I remove the tracking scripts?

We recommend tracing back your steps and deleting the custom pixed previously created.

Here's where you can locate your old integration:

Open Setting > Click on Customer events > Choose the Custom Pixel > Press Delete pixel.






Did this answer your question?