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 over a week ago

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

Watch our tutorial video on how to do a code-based integration with Shopify below.

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, go to: Sales Channels > Online Store > Themes > Click on actions > Edit Code

2. Select the theme.liquid file in the layouts folder. Add the following click tracking script, just before the </head> tag.

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script> 
<script type="text/javascript">
(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');
</script>

Make sure to replace the YOUR ACCOUNT ID with your actual account id. This value can be found in your Profile Settings.

3. Hit save.

4. Next, in your shop's admin environment, go to: Settings > Checkout > Scroll down to the option Order processing and keep scrolling until you see the section named Additional scripts.


In the additional scripts section, locate the Order Status Page block. In this block, paste the following conversion tracking script:

{% if first_time_accessed %} 
<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
(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('conversion', '{{ order_number }}', {{ order.subtotal_price }}/100, {
coupons: {{ order.discounts | map: 'code' | json }},
currency: "{{ order.currency }}",
customer_id: "{{ order.email }}",
});
</script> {% endif %}

As you did with the click tracking bit, make sure to replace YOUR ACCOUNT ID with your actual account id!

5. Hit save.

6. 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 - Tapfiliate's software works with first-party cookies, which only work for the domain in which they are initially sorted. These cookies cannot track across different domains. For more information, check out our How tracking works article.

What happens if I have both the code-based integration and the plug-in installed 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 removing the Tapfiliate scripts that were previously installed.

Here's where you can locate your old tracking scripts:

  • Removing the click tracking script

    Go to Sales Channels > Online Store > Themes > Click on actions > Edit Code. Select the theme.liquid file in the layouts folder. You would have installed the click tracking script, before the </head>.

  • Removing the conversion tracking script

    Go to Settings > Checkout > Scroll down to the option Order processing and keep scrolling until you see the section named Additional scripts.

The scripts you're looking to remove look like the ones in this guide.




Did this answer your question?