How do we know where we can improve without hard data to make those decisions?
This is true in many aspects of business, data helps us make informed decisions to help us improve. This is especially true for an eCommerce website. Data helps us know which products are good sellers, which bring the best return, when the best time to start marketing seasonal lines.
It also helps with our marketing budgets, it lets us see where the best channels are so that we can prioritise those budgets.
Most of us will likely use Google Analytics to track website usage, and with the effectiveness of Google Ads at driving qualified traffic to our website, we want to make sure we have these set up too.
Thankfully, Magento 2 makes the set up easy for us to do.
Google Analytics Tracking
To set up Google Analytics, you’ll first need to go to your [Google Analytics account] an account, if you don’t already have one, it’s easy to set one up.
What we need to do is get our tracking ID, and set up Analytics for eCommerce tracking. After you’ve logged in, head to admin settings.
Then you need to go to Tracking Info > Tracking code, where you’ll be shown the the tracking code. The part you’ll need is the unique tracking number that starts with UA-XXXXXXXX-X. Copy this somewhere as you’ll need it for the next part.
Now go back to Admin and to the eCommerce settings tab.
Here you’ll want to enable this to enable eCommerce tracking and then enable enhanced eCommerce tracking.
Log into your Magento 2 store and go to Stores > Settings > Configuration.
Now head to down to Sales > Google API. Here the top element should be labelled Google Analytics.
Enable this to Yes, this will expand to give you the sections that need to be filled in. Under Account Number add your tracking identifier (starting with UA). Change Anaonymise IP and Enable content experiments if they’re needed.
Hit save config and you’re done.
Google Analytics Ecommerce Tracking
Now, if you’re on Magento 2 Enterprise Edition (EE), the above will be all you need to do, this will have set you up website tracking and advanced tracking for your Magento 2 website.
If however, you’re using Magento 2 Community Edition (CE), this will ONLY have set up basic website tracking, (page views, time on site, bounce rate etc.)
What it won’t have done is added the eCommerce tracking. To track sales in Google Analytics there’s some extra work to be done.
You can either do this using Google’s instructions and update the website code to include the eCommerce tracking. Alternatively, you can use an extension such as Tatvic enhanced eCommerce, where once the extension is installed, you’ll only need to make some adjustments in your Magento admin area to enable eCommerce tracking.
Google Ads Site Tag
For Google Ads (formerly Adwords) global site tag needs to be set up on every page of the website, this will allow Google Ads to track site visits, allow you to add people to your remarketing list, and is required to set up conversion tracking.
Log into your Adwords account and go to Tools > Conversions (if you don’t have a Google Ads account, it’s easy to set one up).
Now you will want to set up a conversion, enter all the details and select the sale/purchase conversion.
You will now be asked how you want to receive the installation tags, select to install the tag yourself.
You’ll now be presented with two tags, the global site tag, and the event snippet. Copy the global site tag and log into your Magento website. Go to Content > Design > Configuration.
Here you’ll be listed with the views of your websites, select to edit the one you want to add your Google Ads conversion tracking to. Once in, expand the HTML head section and scroll down to Scripts and Style Sheets, this is where you’ll add your global site tag.
Next, it’s time to set up the conversion tracking.
Google Ads Conversion Tracking
Go to Stores > Settings > Configurations.
Now head to down to Sales > Google API. Enable the Google Adwords section, and it will expand to show you the settings you need to fill in.
Go back to Google Ads to find your event snippet, which should look something like this.
Use this to fill in the conversion ID and conversion label fields, if any of the other fields need changing, update these, hit save and you’ve finished setting up your conversions for Google Ads.
Bonus: Additional Sitewide Tracking Scripts
For other tracking scripts that you want to add to the website, where the tracking snippet needs to be added on every page (Hotjar for example), is fairly straightforward to set up (the same principle as the Google Ads global site tag above).
- Get your tracking script.
- Log into the Magento admin area.
- Navigate to Content > Design > Configuration.
- Edit the store view you want to add the tracking script to.
- Expand the HTML Head section.
- Paste your tracking script into the Scrips and Style Sheets section.
- Hit save and you’re finished.
The first thing you need to do is get your tracking script, once you have this, log into your Magento admin area and head to Content > Design > Configuration.
Edit the store view you want to add the tracking script to. Expand the HTML head area and locate the Scripts and Style Sheets section, paste your script into here and then save. Your tracking script will now have been added to all page.