• Skip to primary navigation
  • Skip to main content
  • Skip to footer

Merchant Labs

Helping online merchants succeed is what we do best!

  • About
  • Contact
  • My Account

Shopify / March 27, 2017

Shopify Conversion Tracking Using Cart Attributes

Since you cannot use cookies to track information from the shop to the checkout pages (including the Thank You page) I’ve found a nifty way around the problem by using Cart Attributes.

Just like with cookies, I get a name=value type-of mechanism where I can store information that is never shown to the user.

In my case I needed to fire a specific conversion pixel depending on if the user came from a specific source as well as which promotion they came into the shop.

I used CartJS to store the Cart Attributes then used this code on the Additional Scripts section of Admin > Settings > Checkout.

{% if first_time_accessed %}
{% for attribute in attributes %}
{% capture attrname %}{{ attribute | first }}{% endcapture %}
{% capture attrvalue %}{{ attribute | last }}{% endcapture %}
{% if attrname == ‘PUBLISHERNAME’ %}
{% assign pixel_full = ‘|nodi|’ %}
{% assign pixel_90 = ‘|hair90|’ %}
{% assign pixel_70 = ‘|hair70|’ %}
{% assign pixel_50 = ‘|hair50|’ %}
{% capture discount_code %}|{{ attrvalue }}|{% endcapture %}
{% if pixel_90 contains discount_code %}
<!– Offer Conversion: MYWEBSITE – $90 OFF ($59.95) –>
<img src=”https://website.com/aff_l?offer_id=6&adv_sub={{ order_number }}&amount={{ total_price | money_without_currency }}” width=”1″ height=”1″ />
{% elsif pixel_70 contains discount_code %}
<!– Offer Conversion:MYWEBSITE – $70 OFF ($79.95) –>
<img src=”https://website.com/aff_l?offer_id=4&adv_sub={{ order_number }}&amount={{ total_price | money_without_currency }}” width=”1″ height=”1″ />
{% elsif pixel_50 contains discount_code %}
<!– Offer Conversion:MYWEBSITE – $50 OFF ($99.95) –>
<img src=”https://website.com/aff_l?offer_id=2&adv_sub={{ order_number }}&amount={{ total_price | money_without_currency }}” width=”1″ height=”1″ />
{% elsif pixel_full contains discount_code %}
<!– Offer Conversion:MYWEBSITE – FULL PRICE ($149.95) –>
<img src=”https://website.com/aff_l?offer_id=8&adv_sub={{ order_number }}&amount={{ total_price | money_without_currency }}” width=”1″ height=”1″ />
{% endif %}
{% endif %}
{% endfor %}
{% comment %} <script>
if (‘{{ ref_name }}’ == ‘PUBLISHERNAME’) {
alert(‘discount: {{ discount_code }}’);
}
</script>
{% endcomment %}
{% endif %}

Filed Under: Shopify Tagged With: Coding, Javascript

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Footer

Shopify Partner

Let Merchant Labs, with over 15 years experience in ecommerce, help you SUCCEED online! From …

Read More about Shopify Development Services

  • Twitter
  • YouTube

Ajax-Cart Coming Soon

What is Ajax-cart for Shopify? Ajax-cart for Shopify is a big project to bring some of the most wanted features to the Shopify cart page. This page is also known as the basket screen. Its …

more about Ajax-Cart for Shopify

Tags

Apps Script Coding Documentation Javascript MySQL PHP Shopify Liquid

Contact Us

Merchant Labs
Los Angeles, California

P: 424-236-0372
E: [email protected]

Proud Partners For

Copyright © 2025 · Digital Pro on Genesis Framework · WordPress · Log in