Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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 %}
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025