shopify-ga4-kit icon indicating copy to clipboard operation
shopify-ga4-kit copied to clipboard

Uncaught Exception in datalayer-product.js

Open mk-simon opened this issue 9 months ago • 1 comments

I have implemented the ga4-kit into Shopify but was seeing some strange behaviour where the analyzify_productDetail event was not firing on certain product pages.

I've realised that it was an issue with quotes " being used in our Shopify variants.

Screenshot 2024-05-13 105652

I've managed to correct the issue by updating line 21 in datalayer-product.js from

var productVariantTitle = "{{ product.selected_variant.title | default: product.variants[0].title }}"; to var productVariantTitle = {{ product.selected_variant.title | json | default: product.variants[0].title | json }};

and the event now successfully triggers on all my product pages.

Not sure if that is the best way to fix it, but it's working

mk-simon avatar May 13 '24 03:05 mk-simon