Shopify: Difference between revisions
Ben.robson (talk | contribs) |
Ben.robson (talk | contribs) |
||
| Line 62: | Line 62: | ||
Cheat sheet for Variables: <br /> | Cheat sheet for Variables: <br /> | ||
https://www.shopify.co.uk/partners/shopify-cheat-sheet | https://www.shopify.co.uk/partners/shopify-cheat-sheet | ||
Events for Analytics 4: <br /> | |||
View Item: <br /> | |||
Add this to product-template-liquid | |||
<pre> | |||
<script> | |||
window.dataLayer = window.dataLayer || []; | |||
dataLayer.push({ | |||
event: "view_item", | |||
ecommerce: { | |||
currency: "GBP", | |||
items: [ | |||
{ | |||
item_id: {{ product.id }}, | |||
item_name: "{{ product.title }}", | |||
{% if product.vendor %} item_brand: "{{ product.vendor }}", {% endif %} | |||
price: {{ product.price | money_without_currency }}, | |||
{% if product.type %} item_category: "{{ product.type }}", {% endif %} | |||
google_business_vertical: "retail", | |||
id: "{{ product.id }}" | |||
} | |||
] | |||
}, | |||
}); | |||
</script> | |||
</pre> | |||
Revision as of 10:36, 2 July 2021
Tag Manager
Add Tag Manager to theme: Modify Theme
"online store" -> "..." or "Actions" -> "edit HTML / CSS"
Modify theme.liquid
Google Tag Manager will also need to be added to Checkout's additional settings to track conversions
Conversion Tracking Code
Google Tag Manager will also need to be added to Checkout's additional settings to track conversions
In "settings" -> "checkout" -> "additional settings"
{% if first_time_accessed %}
<script>
var dataLayer = window.dataLayer || [];
dataLayer.push({'order_id' : '{{ order_number }}', 'order_value' : '{{ total_price | money_without_currency }}', 'event' : 'order-submitted'});
</script>
{% endif %}
to add product ids add within the code above:
dataLayer.push({ 'product_ids' : [{% for line_item in line_items %}{{ line_item.product_id }}{% unless forloop.last == true %}, {% endunless %}{% endfor %}] });
Product Feed
The below App is free to use & should do most of the setup for you:
https://apps.shopify.com/google
After installing the App a Google account with access to the Merchant Centre needs to sign in.
DO NOT sign in using one of our Master email addresses, instead you can either:
- Ask the client to do this, if they don't have access to Merchant Center we can try to add them. - Create a new email address that only has access to this Merchant Center & sign in with this instead.
Then the below needs to be done, in this order otherwise it won't send the products through & you'll have to start from scratch:
- Make sure the Store requirements are met & confirm these, if they aren't then send this back to the client so they can add whats necessary. - Under Product Feed, start the setup process. - Connect the Merchant Centre on the settings tab. - Specify the Target Market & set the Shipping settings to Manual (These will need to be added to Merchant Center by someone afterwards).
If this has been done correctly then the products should now be available within the Merchant Center account.
Alternatively, Shopify does provide you with the Product feed URL for your store.
To access this, you will need to append .atom to either all of your collections or to a specific collection URL.
For example:
"yourstorename.com/collections/all.atom" "yourstorename.com/collections/collectionname.atom"
Other
Cheat sheet for Variables:
https://www.shopify.co.uk/partners/shopify-cheat-sheet
Events for Analytics 4:
View Item:
Add this to product-template-liquid
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: "view_item",
ecommerce: {
currency: "GBP",
items: [
{
item_id: {{ product.id }},
item_name: "{{ product.title }}",
{% if product.vendor %} item_brand: "{{ product.vendor }}", {% endif %}
price: {{ product.price | money_without_currency }},
{% if product.type %} item_category: "{{ product.type }}", {% endif %}
google_business_vertical: "retail",
id: "{{ product.id }}"
}
]
},
});
</script>