Track Shopify Purchases

Able CDP Shopify purchase tracking attributes Shopify purchases to original customer sources, allowing Able to attribute them correctly.

Track Purchases

To track Shopify purchases, add the following code to the Settings — Checkout — Additional scripts in Shopify:

<script>
(function() {
 var el = document.createElement('script');
 el.src = 'https://app.formsable.com/ue.js';
 el.async = 'true';
 el.addEventListener('load', function() {
   uipe('init', "%%FUNNEL_MARK%%")
   uipe('track', 'Purchase', {
     deal_value: '{{ total_price | money_without_currency }}',
     deal_currency: "{{ currency }}",
     deal_items: [ {% for line_item in line_items %}
       {
         sku: "{{ line_item.sku }}",
         qty: {{ line_item.quantity }},
         price: '{{ line_item.line_price | money_without_currency }}',
       },
     {% endfor %} ],
     order_id: {{ order_number }},
     keys: {
       email: "{{ checkout.email }}",
       phone: "{{ checkout.customer.phone }}",
       client_id: "shopify:{{ checkout.customer.id }}",
     },
     lead: {
       firstName: "{{ checkout.billing_address.first_name }}",
       lastName: "{{ checkout.billing_address.last_name }}",
       city: "{{ checkout.billing_address.city }}",
       country: "{{ checkout.billing_address.country_code }}",
       state: "{{ checkout.billing_address.province_code }}",
       zip: "{{ checkout.billing_address.zip }}",
     },
   })
 })
 document.head.appendChild(el);
})();
</script>

(Where %%FUNNEL_MARK%% is the unique funnel identifier.)

Track Page Views and Visitor Sources

It's strongly recommended to add Able CDP visitor tracking code to the rest of the website pages as well. It records Facebook and Google click ids when a visitor first comes to the website, and uses Google Analytics Client Id in addition ad platform browser ids to better track customers. (Google Analytics must be installed for this tracking script to work correctly.)

This code can be added to Shopify store by editing the theme.liquid template or using GTM.

Visitor tracking code example below supports tracking standard Shopify Lead and Contact forms. It needs to be extended if you're using additional lead generating plugins or landing pages.

<script>
(function() {
 var el = document.createElement('script');
 el.src = 'https://app.formsable.com/ue.js';
 el.async = 'true';
 el.addEventListener('load', function() {
   uipe('init', "%%FUNNEL_MARK%%");
   uipe('track', 'PageView');
   (function() {
   var leadForm = document.getElementById('contact_form');
   if (leadForm) {
   leadForm.addEventListener('submit', function () {
     var leadParams = {
       keys: {
   email: leadForm.elements['contact[email]'] && leadForm.elements['contact[email]'].value, phone: leadForm.elements['contact[phone]'] && leadForm.elements['contact[phone]'].value
       }, lead: {
   
       }
     };
     uipe('track', 'Lead', leadParams);
   });
   }
   })();  
 });
 document.head.appendChild(el);
})();
</script>

Next Steps

After Shopify purchases begin to appear in Able CDP under Customers — Purchases tab, set up one or a few of the supported outbound Purchase conversion integrations listed below. If you're currently sending Purchase events to the same service using another integration or tracking code, it's recommended to disable sending Purchase conversions with it and only send Purchase conversions using Able CDP Conversions API integration to prevent duplicates.

FAQ and Troubleshooting

Duplicate Purchase conversions appear in Facebook Ads Manager or duplicate events warning appears in Facebook Events Manager

When Able is used, conversion events that are sent by it to the Facebook Conversions API should not be sent using Facebook Pixel as it'll lead to event duplication.

Able doesn't send deduplication parameters in its Conversions API calls as it'll lead to additional customer tracking data collected by Able CDP and sent to Conversions API to be ignored altogether in favor of the Pixel event. This is done by design on the Facebook end.

To prevent duplicates from appearing, send PageView events to Facebook Pixel from the browser and use Able to send Lead and Purchase events attributed to the original visitor.

Doing this in Shopify requires the following steps:

  1. Disable Shopify Facebook Data Sharing
  2. Edit Shopify theme and add Facebook Pixel code using the instructions to Manually add pixel code to website

This should resolve event duplication issues by making sure that each type of event is sent to Facebook Pixel and Conversions API once.

What else you can do

Send Purchase Conversions

Send Purchases to Google Analytics

Send attributed Purchases to Google Analytics from any source, such as a sending a closed won CRM deal, a successful Stripe Invoice payment or an e-commerce purchase that has been successfully paid.

Send Purchases to Google Ads

Sending conversions to Google Ads is an extremely common integration scenario. Its used to add conversion value to Google Ads’ reports, allowing to report on ROI, as well as to use performance-based targeting and optimization capabilities.

Send Purchases to Facebook Conversions API

Attributing conversions to Facebook Ads is a common task, however doing it with sufficient precision is hard. Sales might happen in CRM, or, when they happen online, customer might not come back to the website, so tracking with Facebook Pixel JS produces substandard results. Able solves this problem with its Facebook Conversions API integration.