On this page

How to track the Initial Checkout conversion:

All scripts placed in the Settings > Advanced Settings > Additional Scripts > First Upsell Page Scripts field are going to fire on the first post-purchase offer page. This will allow you to track the initial checkout order conversion and other order data. The OCU post-purchase offer page is the next page seen after the customer completes their initial order, so most conversion pixels will want to be fired then.

How to track the Upsell and Downsell Offers conversions:

All scripts placed in the Settings > Advanced Settings > Additional Scripts > Thank You Page Scripts field are going to fire if/when the customer lands on the TY page. This will allow you to track the offers conversions and other data.

The value for your post-purchase offer funnel will be gathered and reported as an aggregate amount (the total value of any upsell/downsell offers taken) when the script fires once the Thank You page is reached. 

That also means that no scripts will fire if the customer fails to reach the OCU Thank You page due to abandoning the post-purchase funnel.

*Important Note: The "Additional Scripts" fields for OCU will only fire the scripts on the "live" first upsell page and thank you pages respectively the very first time those pages load. The scripts will not fire again if the page is refreshed/reloaded to prevent duplicate fires and over-reporting. No scripts added to these fields will fire in "preview" mode.

Using Shopify Liquid Variables:

 You can use Shopify liquid variables for the objects "checkout", "line_item", "customer" and  "shop" for creating tracking scripts. You can find more details about this in Shopify's help article here: https://help.shopify.com/themes/liquid/objects

Due to some Shopify limitations and peculiarities of the OneClickUpsell workflow, some of the liquid variables are not supported

Notes on using liquid variables in your scripts/codes: 

1. You can skip the checkout object when referring to checkout variables. 

For example you can use:

value = {{ checkout.total_price | money_without_currency }} OR value = {{ total_price | money_without_currency }}.

order_number = {{ checkout.order_number }} OR order_number = {{ order_number }}

2. The variables order_id, order_name and order_number can only send data when inserted in the Thank You Page Scripts field because the order number can only be obtained on the Thank You Page. 

3. line_items, total_price, tax_price, subtotal_price, shipping_price variables will only return data for offer items (with no information from the initial checkout) when inserted in the Thank You Page Scripts field. It send data about the initial checkout when inserted in the First Upsell Page Scripts field. 

4. Don't include {% if first_time_accessed %} and {% endif %} in the beginning and end of the scripts you add. OCU already has this logic built in so that the script can only be fired once. It will not fire again if the page is reloaded. Having that included in your scripts will likely cause them to not fire properly when used with OCU. 

5. If you need scripts to be fired only when an upsell/downsell offer product(s) is bought, you'll need to enclose the scripts in the if condition (only for scripts inserted in the Thank You Page Scripts field):

{% if checkout.offers_bought %}
All scripts that should be fired only when offer product(s) are purchased and not when no offer product(s) were purchased…
{% endif %}
 

6. Discount variables can only return data about the initial checkout. So scripts that contain discount variables should be inserted in the First Upsell Page Scripts field.

7. If your script uses the "src" attribute, to prevent an issue with your script loading when the customer has a slow internet connection, you need to add {% external_script %} before the script that contains the src attribute and {% endexternal_script %} at the end of this script.

Example:

{% external_script %}
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
{% endexternal_script %}

Supported Liquid Variables for each Object:

"checkout" object

  • checkout.billing_address
  • checkout.buyer_accepts_marketing
  • checkout.discounts
  • checkout.discounts_amount
  • checkout.discounts_savings
  • checkout.email
  • checkout.line_items
  • checkout.note
  • checkout.order_id
  • checkout.order_name 
  • checkout.order_number
  • checkout.requires_shipping
  • checkout.shipping_address
  • checkout.shipping_method
  • checkout.shipping_methods
  • checkout.shipping_price
  • checkout.subtotal_price
  • checkout.tax_lines
  • checkout.tax_price
  • checkout.total_price

"line_item" object

  • line_item.grams
  • line_item.line_price
  • line_item.price
  • line_item.product
  • line_item.product_id
  • line_item.quantity
  • line_item.requires_shipping
  • line_item.sku
  • line_item.taxable
  • line_item.title
  • line_item.url
  • line_item.variant
  • line_item.variant_id
  • line_item.vendor

"customer" object

  • customer.accepts_marketing
  • customer.addresses
  • customer.addresses_count
  • customer.default_address 
  • customer.email
  • customer.first_name
  • customer.has_account ( It is "true" if the customer is logged in during checkout and "false" if they aren't logged in)
  • customer.id
  • customer.last_name
  • customer.name
  • customer.orders_count
  • customer.total_spent

"shop" object

  • shop.address
  • shop.collections_count
  • shop.currency
  • shop.domain
  • shop.email
  • shop.locale
  • shop.money_format
  • shop.name
  • shop.permanent_domain
  • shop.products_count
  • shop.secure_url
  • shop.url

Example Conversion Scripts:

Google Adwords Conversion 

This is just an example, you will need to add in your Adwords Conversion ID and Conversion label for the scripts in the correct locations for it to work with your Adwords account. (screenshot with details)

<!-- Adwords SCRIPT for First Upsell Page to track initial conversion -->

<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'AW-123456789');
</script>

<script>
gtag('event', 'conversion', {
'send_to': 'AW-123456789/tEsTCM-tEsTBEMXytEsT',
'value': '{{ total_price | money_without_currency }}',
'currency': 'USD',
'transaction_id': {{ 'now'|date:'%s' }},
});
</script>

Notes: We replace transaction_id, order_number, or order_id with {{ 'now'|date:'%s' }} because the order number is not available on the first upsell page and transaction variables are not supported by the OCU app there. The value passed from the first upsell page is total/subtotal value taken from the initial checkout.

You can use 'value': {{ total_price | money_without_currency | remove: "," }} instead of
'value': '{{ total_price | money_without_currency }}' if you'd like.

<!-- Adwords SCRIPT for Thank You Page to track offer product conversion(s) -->

<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'AW-123456789');
</script>

<script>
gtag('event', 'conversion', {
'send_to': 'AW-123456789/tEsTCM-tEsTBEMXytEsT',
'value': '{{ total_price | money_without_currency }}',
'currency': 'USD',
'transaction_id': '{{ order_id }}',
});
</script>

Notes:
For the Thank You Page Scripts field we can use order_id, order_number or order_name variables here. The value passed from the TY page is the total/subtotal value taken from upsell/downsell offer product(s) only. It doesn't report any data back about the initial order.

Facebook Pixel configured with the "Purchase" event 

This is just an example, you will need to add in your Facebook Pixel ID in the correct locations for it to work with your Ads Manager account.

<!-- Facebook Conversion Pixel Code -->

<script type="text/htmlpart" >
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window,
document,'script',
'//connect.facebook.net/en_US/fbevents.js');
fbq('init', 'YOUR FB Pixel ID HERE');
fbq('track', 'PageView');
fbq('track', 'Purchase', {value: '{{ checkout.total_price | money_without_currency }}', currency: 'USD'});
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=YOUR FB Pixel ID HERE&ev=PageView&noscript=1"
/></noscript>

Note: We recommend to use our built-in Facebook Pixel Integration, but if you want to add the "Purchase" event to track conversions and value in an additional FB pixel account, then you can use the script above as well. 

Did this answer your question?