shopify-ga4-kit
shopify-ga4-kit copied to clipboard
Uncaught Exception in datalayer-product.js
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.
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