Visual UGC Docs
Search
K

Shopify

Tracking Pixel

When adding the Visual UGC Tracking Pixel to your Shopify Store, there are a few different approaches in which you can take depending on your Shopify Store license. These include:
Details on adjusting the Theme Template and adding to the Shopify Checkout are available below.

Adding to Shopify Checkout

Adding the Visual UGC Tracking Pixel to the Shopify Checkout is the easiest approach for clients who either do not wish to edit their Shopify Template, or do not have a license which allows them to do so.
The main limitation of this implementation is it will mean that the Visual UGC Tracking Pixel will only be able to Track when a customer first interacts with a Visual UGC Widget, and if they go on to Purchase the associated Product(s). For tracking of other steps, an analytics tool, like Google Analytics, will need to be used.
To add the Tracking Pixel to the your Shopify Store Checkout, go to Settings > Checkout and find the Order Processing section of the page. Here you will find a field called Additional Scripts where you can add the Tracking Pixel code.
A sample of the code you can put in here to Track the Purchase, including the relevant Products, Quantity and Values is available below.
<img src="https://stp.stack.la/record.png?event=purchase&ext_currency={{ shop.currency }}&product_id=<div data-gb-custom-block data-tag="for">{{ line_item.sku }},</div>&ext_amount=<div data-gb-custom-block data-tag="for">{{ line_item.line_price | money_without_currency }},</div>&ext_quantity=<div data-gb-custom-block data-tag="for">{{ line_item.quantity }},</div>" height="1" width="1" />
Simply copy this code, add it to the Additional Scripts section and hit Save.

Adjusting Theme Template

For those clients who have the ability to edit their Shopify Store Template (Shopify Plus), it is possible to add the Tracking Pixel to each relevant template within your site to track the end to end progress of a customer.
To edit your Theme, you will want to log into your Shopify Store and within the Admin section, select Online Store > Themes.
From the resulting page, select the Actions dropdown under the Current Theme section and click Edit Code from the dropdown.
Once you have reached the Editor, the templates you may wish to edit include:
  • product.liquid - Product Page
  • cart.liquid - Cart Page
  • checkout.liquid - Checkout Page
For each of these, you will want to inject the relevant Tracking Pixel Events and Parameters which you want to track. Some samples are included below.
Product Page
<img src="https://stp.stack.la/record.png?product_id={{ product.id }}&event=product_page_view"">
Checkout Page
<img src="https://stp.stack.la/record.png?event=purchase&ext_currency={{ shop.currency }}&product_id=<div data-gb-custom-block data-tag="for">{{ line_item.sku }},</div>&ext_amount=<div data-gb-custom-block data-tag="for">{{ line_item.line_price | money_without_currency }},</div>&ext_quantity=<div data-gb-custom-block data-tag="for">{{ line_item.quantity }},</div>" height="1" width="1" />

Product Page Widgets

All Visual UGC's Widgets are designed to support Dynamic Filtering by Product Tags, meaning it is possible for a brand to create a single Widget for their Shopify Product Pages and dynamically change the content that is displayed based upon the relevant Product being displayed.
As such, to start the process of adding Widgets to your respective Shopify Product Pages, you can either create a new Widget, or select one that already exists within your Stack. In either scenario, once you are happy with the Widget you wish to use on your Shopify Store, select Embed Code and copy the provide Embed Code.
Now before we add this to your Shopify Store, we will need to make addition to the code. To ensure the Widget shows the correct Product we will want to pass the Product ID from Shopify to the Widget and thus will want to add the following code: data-tags="ext:{{ product.id }}" to the DIV part of the code so it looks similar to the below:
<div id='stackla-goconnect-widget' data-widget-id="{{widget-id}}" data-tags="ext:{{ product.id }}" ></div>
<script type='text/javascript'>
(function (d) {
// embed.js CDN
var cdn = window.StacklaGoConnectConfig ? window.StacklaGoConnectConfig.cdn : 'assetscdn.stackla.com';
var t = d.createElement('script');
t.type = 'text/javascript';
t.src = 'https://' + cdn + '/media/js/common/plugin_goconnect_embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(t);
}(document));
</script>
Note, if instead of using the Product ID to link your Shopify Products with your Visual UGC Product Tags, you are using the Product SKU, you will need to add the following code before your Widget loads, <div data-gb-custom-block data-tag="assign"></div> and add the following into the Widget Embed code: data-tags="ext:{{ current_variant.sku }}". This will update the Widget Embed code to look similar to the below:
<div id='stackla-goconnect-widget' data-widget-id="{{widget-id}}" data-tags="ext:{{ current_variant.sku }} " ></div>
<script type='text/javascript'>
(function (d) {
// embed.js CDN
var cdn = window.StacklaGoConnectConfig ? window.StacklaGoConnectConfig.cdn : 'assetscdn.stackla.com';
var t = d.createElement('script');
t.type = 'text/javascript';
t.src = 'https://' + cdn + '/media/js/common/plugin_goconnect_embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(t);
}(document));
</script>
Next you will want to log into your Shopify Store and within the Admin section, select Online Store > Themes.
From the resulting page, select the Actions dropdown under the Current Theme section and click Edit Code from the dropdown.
This will load the respective code editor for your theme. Navigate to find the template for your Product Page, which should be called product.liquid. Select this option and then insert your Widget Embed code.
Once done, you can hit save and your Widget will now dynamically update each time someone goes to a Product Page to only show content relating to that Product.