Firing a Pixel Only When a Specific Variant ID is Purchased

Highlighted
Tourist
13 0 1

Hello,

 

We are trying to fire a pixel only when specific variant ID's are purchased, but are not able to get the code to work. The Base pixel (Page View pixel) is implemented above the below code. The below code is our current setup in the Checkout Additional Scripts box:

 

<script>
{% for item in checkout.line_items %}
{% if item.variant == VARIANTID %}
  
   PIXEL

{% endif %}
{% if item.variant == VARIANTID %}

   PIXEL

{% endif %}
{% if item.variant == VARIANTID %}

   PIXEL

{% endif %}
{% if item.variant == VARIANTID %}

   PIXEL

{% endif %}
{% if item.variant == VARIANTID %}

   PIXEL

{% endif %}
{% if item.variant == VARIANTID %}

    PIXEL

{% endif %}
{% endfor %}
</script>

Is anyone able to see any errors that would cause this code to not work? Any guidance or assistance would be greatly appreciated!

 

Thanks.

0 Likes
Highlighted
Shopify Partner
87 29 23

item.variant would be the entire variant object, replacing that with item.variant_id would fix that up!

Is your store fast enough? Compare your store's speed against hundreds of others for free with our benchmarker - https://www.rvere.com/
1 Like
Highlighted
Tourist
13 0 1

Hi Alex,

 

Thank you very much for the reply and tip!

So it would be "item.variant_id", not "item.variant.id"?

 

Thanks again for your input!

0 Likes
Highlighted
Shopify Partner
87 29 23

Yup exactly

Is your store fast enough? Compare your store's speed against hundreds of others for free with our benchmarker - https://www.rvere.com/
1 Like