Liquid, JavaScript, themes, sales channels
Hi,
I want to get product title and variant title sent to Google Analytics like this "Product title - Variant title"
I managed this by doing the following:
'item_name': '{{ product.title }} - {{ product.selected_or_first_available_variant.title }}'
However when there was no variants the variant title defaulted to "Default title":
'Running Shoe - Default Title'
One solution might be to do something similar to:
'item_name': '{{ product.title }}{% if product.selected_or_first_available_variant.title != 'Default Title' %} - {{ product.selected_or_first_available_variant.title }} {% endif %}'
However it seems fragile. Any ideas for a better solution?
Thank you.
I think this might help.
{% unless product.has_only_default_variant %} - {{ product.selected_or_first_available_variant.title }}{% endunless %}
User | RANK |
---|---|
38 | |
28 | |
13 | |
11 | |
8 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023