Overview SaaS
Understanding traffic of your commerce channel is extremely important in unifying you branding strategy, marketing strategy and personalised content strategy.
In this article we will go through step by step instructions to integrate Google analytics and Google tag manager in order to enable these insights in SaaS default themes.
Prerequisites:
- You have a google account ( https://www.google.co.uk/ and click sign in to start the account creation process)
- You have enabled google analytics ( https://support.google.com/analytics/answer/1008015?hl=en )
- You have enabled google tag manager ( https://support.google.com/tagmanager/answer/6103696?hl=en )
- You have installed "Tag Assistant" Chrome extension ( https://chrome.google.com/webstore/detail/tag-assistant-by-google/kejbdjndbnbjgmefkgdddjlbokphdefk?hl=en )
Integration
Google Analytics
- Start with creating analytics account
- Enter account name
- Specify that you wish to track website data
- Add website name, URL, industry and time zone
- Under Admin > Property > Property settings > Tracking code, copy "Global Site Tag (gtag.js)" code
- Login to Admin app and navigate to CMS section
- Search for "header_include" and add the code to all CMS body element for all languages. If the include does not exists create one using SHOPCODE_header_include URI pattern
- Save the content and clear cache
- Go back to Analytics panel and click Property > All website data > Realtime > Overview
- View home page on your website
- Refresh the realtime overview - it should say that there are visitors on the website
Google Tag Manager
- Start with creating tag manager account
- Specify account name, country, container URL and set target platform as Web
- Copy two snippets provide for the "head" and "body" tags
- Create a new Tag, for example Google Analytics: Universal and set it to track all pages, use your GA tracking ID as a variable
- Submit and publish container
- Login to Admin app and navigate to CMS section
- Search for "header_include" and add the "head" code to all CMS body element for all languages. If the include does not exists create one using SHOPCODE_header_include URI pattern
- Save the content
- Search for "body_include" and add the "body" code to all CMS body element for all languages. If the include does not exists create one using SHOPCODE_body_include URI pattern
- Save the content and clear cache
- View home page on your website
- Open "Tag Assistant" extension, click "enable" and click "start recording"
Google Analytics Commerce Events
- Login to Google Analytics account
- Open property > Property view > Ecommerce settings and click enable Ecommerce and save changes
- Login to Admin app and navigate to CMS section
- Search for "footer_include" and add the below code (click expand button to view) to all CMS body element for all languages. If the include does not exists create one using SHOPCODE_footer_include URI pattern
- Save the content and clear cache
- Visit your site
- Open "Tag Assistant" extension, click "enable" and click "start recording"
- Go to the page and try to go through the checkout process
Note that it may take up to 24h for the event to appear in google analytics
- Check tags in the extension, click "Check contained tags" to load data layer, click data layer tab
For versions up to 4.0.0 footer_include must contain full GA/GTag script. Below is an example integration script for default theme
In version 4.1.0+ variant of the above script was included as gtag.js resource file and hence in order to enable it only the following code snippet is required:
Provided script supports the following events:
Page | Event | Event label | Event structure | Comments |
---|---|---|---|---|
Login page | login | { method : 'customer' } | tracks clicks of '.js-login-submit' | |
login | { method : 'registration' } | tracks clicks of '.js-register-submit' | ||
Category and Search pages | view_item_list | list: View | 'items': [ { 'id': _code, 'name': _name, 'list_name': _list, 'brand': _brand, 'category': _cat or _dim, 'variant': _fc, 'list_position': 1, 'quantity': 1, 'price': _price } ] | tracks product impressions |
add_to_cart | list: Add x | 'items': [ { 'id': _code, 'name': _name, 'list_name': _list, 'brand': _brand, 'category': _cat or _dim, 'variant': _fc, 'list_position': 1, 'quantity': 1, 'price': _price } ] | add to cart events triggered by '.js-buy' buttons | |
Product details page | view_item | pdp: View | 'items': [ { 'id': _code, 'name': _name, 'list_name': _list, 'brand': _brand, 'category': _cat or _dim, 'variant': _fc, 'list_position': 1, 'quantity': 1, 'price': _price } ] | tracks product views |
add_to_cart | pdp: Add x | 'items': [ { 'id': _code, 'name': _name, 'list_name': _list, 'brand': _brand, 'category': _cat or _dim, 'variant': _fc, 'list_position': 1, 'quantity': 1, 'price': _price } ] | add to cart events triggered by '.js-buy' buttons | |
Cart page | add_to_cart | cart: Add X | 'items': [ { 'id': _code, 'name': 'Cart', 'list_name': _list, 'brand': _brand, 'variant': _fc, 'list_position': 1, 'quantity': 1, 'price': _price } ] | add to cart events triggered by quantity updates |
remove_from_cart | cart: Remove X / cart: Remove all | 'items': [ { 'id': _code, 'name': 'Cart', 'list_name': _list, 'brand': _brand, 'variant': _fc, 'list_position': 1, 'quantity': 1, 'price': _price } ] | remove from cart event triggered by quantity updates | |
begin_checkout | cart | 'items': [ { 'id': _code, 'name': 'Cart', 'list_name': _list, 'brand': _brand, 'variant': _fc, 'list_position': 1, 'quantity': 1, 'price': _price } ] | tracks beginning of the checkout process | |
Checkout page | login + checkout_progress | login: customer | { method : 'customer' } | tracks clicks of '.js-login-submit' |
login + checkout_progress | login: registration | { method : 'registration' } | tracks clicks of '.js-register-submit' | |
login + checkout_progress | login: guest | { method : 'guest' } | tracks clicks of '.js-guest-submit' | |
checkout_progress + set_checkout_option | ship: "shipping method name" | tracks shipping method selections | ||
checkout_progress + set_checkout_option | payment: "payment method name" | tracks payment method selections | ||
purchase | confirm | { 'transaction_id': _tx, 'affiliation': null, 'value': _rev, 'currency': _curr, 'tax': _tax, 'shipping': _shp, 'items': _items, 'event_label': 'confirm' } | tracks clicking payment button |
Resources
Google structured data tool
https://search.google.com/structured-data/testing-tool/
This is a useful tool to help analyse schema.org meta data in your pages.