Cannot Understand Why This is Not Working.

Highlighted
Tourist
11 0 0

We are trying to fire a pixel only when a specific variant ID is purchased, but we cannot get it to fire properly.

I can confirm that the product with the variant ID in our code has been purchased since the pixel has been installed, but still nothing is showing as active within Google Ads:

 

<script>
{% for line_item in checkout.line_items %}
{% if line_item.variant_id == 31540684161113 or line_item.variant_id == 31540684193881 or 
  line_item.variant_id == 31540684226649 or line_item.variant_id == 31129333956697 or 
  line_item.variant_id == 31442383700057 or line_item.variant_id == 31129324191833 or 
  line_item.variant_id == 31129324257369 or line_item.variant_id == 31129326846041 or 
  line_item.variant_id == 8836611604597 or line_item.variant_id == 8836611670133 or 
  line_item.variant_id == 8836614455413 or line_item.variant_id == 8836709318773 or 
  line_item.variant_id == 8836709384309 or line_item.variant_id == 8836709351541 or 
  line_item.variant_id == 8836709417077 or line_item.variant_id == 20643569991769 or 
  line_item.variant_id == 20643561275481 or line_item.variant_id == 20643570090073 or 
  line_item.variant_id == 20643570024537 or line_item.variant_id == 20643570057305 or 
  line_item.variant_id == 20643570122841 or line_item.variant_id == 20643562487897 or 
  line_item.variant_id == 20643562553433 or line_item.variant_id == 20643562520665 or 
  line_item.variant_id == 20643562586201 %}
  gtag('event', 'conversion', {
      'send_to': 'PIXELID,
      'value': {{checkout.total_price | money_without_currency}},
      'currency': 'USD',
      'transaction_id': '{{ order.order_number }}'
  });
{% endif %}
{% endfor %}
</script>

PIXELID is the pixelID / conversion ID in the real version. The Google Ads global snippet is placed above this script, and again I've confirmed that the variant ID is matching what is listed above, and yet it is still not firing when those variant IDs are purchased.

 

What is the issue here? Are we trying to establish a variable that we cant use? Maybe an issue with all of the or statements?

Are we accessing the wrong thing here? Should we be checking for product ID or something else instead?

 

Any help would be greatly appreciated.

0 Likes
Highlighted
Tourist
11 0 0

The above is placed in the Additional Checkout Scripts box.

0 Likes