Conversion Tracking
From Shopify Wiki
Conversion tracking describes the practice of integrating little “bugs” into the checkout process which report back to a centralized third party server when products are sold. This is commonly also described as “Conversion Tracking”.
Contents |
Tracking orders
Tracking pixels — or any conversion tracking code — can be added to your Shopify conversion page — known as the Thank You page in Shopify-speak — by going to Preferences → Checkout & Payment in your shop admin and adding said pixel or code in the “Additional Content & Scripts'” text box.
In that text box, you are able to access the shop liquid object and you should find all the variables which are customarily available in order notification emails.
Example
Your tracking system asks you to integrate a tracking pixel like this:
<img src="https://www.tracking.com/u?amount=<AMOUNT>&order-id=<ORDER_ID>¤cy=<CURRENCY>" height="1" width="20" />
Looking at the above example we know that we need:
- full money amount of order. Probably in dollars : {{ total_price | money_without_currency }}
- A unique order id. order_number will print out the name of the order such as #2322 without the hash character which will suit our purposes: {{ order_number }}
- Our shops currency. We can either hardcode this or use {{ shop.currency }}
Let's replace the placeholders with actual liquid tags:
<img src="https://www.tracking.com/pixel.gif?amount={{ total_price | money_without_currency }}&order-id={{ order_number }}¤cy={{ shop.currency }}" height="1" width="1" />
When a customer reaches the last page of the checkout the code that will actually be delivered to his browser will then look like this:
<img src="https://www.tracking.com/pixel.gif?amount=55.34&order-id=4343¤cy=USD" height="1" width="1" />
Conditional integration
Some providers ask you to only show their tracking pixels if the customer came with a certain reference parameter ( usually ref, source or r ).
Shopify stores such values with the orders and makes them available using landing_site_ref.
For example, say affiliate provider TrackingX wants you to include their pixel in the checkout but they ask you to only show the pixel for customers that come through their referrals.
To identify users that came through their system we simply tell TrackingX to sent all customers to your stores front page http://www.example.com but add a little extra reference to it that only TrackingX uses. The URL you register with them looks like this:
http://www.example.com/?ref=tracking-x
The ?ref=tracking-x is something unique which we just made up. We will use it on the last page of the checkout to verify that a given order came by someone referred by TrackingX.
Let's now head to the Additional Content & Scripts section of your Checkout & Payment page and add this script:
{% if landing_site_ref == 'tracking-x' %}
<img src="https://www.trackingx.com/pixel.gif?amount={{ total_price | money_without_currency }}&order-id={{ order_number }}¤cy={{ shop.currency }}" height="1" width="1" />
{% endif %}
Now we'll only show the tracking pixel for people who entered the service with ?ref=tracking-x attached to the URL.
Need to describe the content of the cart? Look here
Here's an example of tracking pixel — used for Commission Junction — that reports the sku, amount and quantity of each line item:
<img src="https://www.emjcd.com/u?CID=YOURCID&TYPE=YOURTYPE&METHOD=IMG&CURRENCY={{ shop.currency }}&OID={{ order_number }}{% for line_item in line_items %}&ITEM{{ forloop.index }}={{ line_item.sku }}&AMT{{ forloop.index }}={{ line_item.line_price | money_without_currency }}&QTY{{ forloop.index }}={{ line_item.quantity }}{% endfor %}" height="1" width="20" />
Are you using Adwords?
Shopify wrote up a tutorial for you: Where do I place my Google Adwords tracking code?

