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 %}
Leave a Reply
You must be logged in to post a comment.