Home > How to: Google Analytics
(Last Updated On: August 2, 2018)
Google Analytics is a very powerful tool to track engagement. It can, however, be challenging to set up and make sure events are firing. Please read this doc carefully and feel free to reach out to our support team if you need more help.
Google Tag Manager users, please read this first.
Your Google Analytics tracking code can be found in the Admin section of your Google Analytics account. It will be found in the Tracking Code section.
There are three unique versions of the Google tracking code:
- gtag (gtag.js) gtag.js — Google Analytics (This is the new and improved tracking through Google)
- ga (analytics.js) analytics.js – Universal Analytics (This is currently the most commonly used)
- _gaq (ga.js) ga.js – Google Analytics (This is legacy code)
Please note that there is a very big difference in the syntax between these versions, and using the correct one will support the successful implementation of the tracking of SnapEngage chat events.
It should look like 1 of 3 examples below.
ga.js is a legacy library and we, but mainly Google, recommend you use the latest version of analytics.
Here is a reference guide from Google that can show the difference in syntax between Legacy code and Universal Analytics: https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs
Here is a reference guide from Google that can show the difference in syntax between Universal Analytics and the new Google Analytics: https://developers.google.com/analytics/devguides/collection/gtagjs/migration
Once both sets of code are safely installed on your site, you will want to identify what SnapEngage events you want to track in Google Analytics. Almost all events in our developer section can be tracked. (Click here and here to see the available events. Please note that these events will need to be coded out to use, so have your developer handy.)
Find your SnapEngage code snippet on your website and then you can place the Google tracking code BELOW the SnapEngage code snippet.
Now you are ready for your event coding, it would be best to use some sort of text editor to get this all ready. Refer to this doc to learn about all the tracking events https://help.snapengage.com/tracking-events-with-google-analytics/
Sorry to send you to another doc but if we placed all the tracking events here, this doc would be extremely long.
You are almost there! To track your new events, simply take your SnapEngage code snippet and place the Google Analytics events code into the API section (as noted in the SnapEngage code). Be sure not to remove or modify other parts of the snippet.
Here is your original code snippet from SnapEngage. About halfway down is an API section.
Your final snippet should look like this:
If you will be using Google Tag Manager, you need to install SnapEngage via GTM and calling the Google Analytics events in GTM.
Also, if your team is using Google Tag Manager, there are a few additional steps to take. For more information on using Google Tag Manager, please visit here - https://www.google.com/analytics/tag-manager/?hl=en_US
You may already have your Google Analytics code installed via Tag Manager. You will now want to add your SnapEngage+Google Analytics code through a tag.
Once you have that in there, you will also want to add your Google Analytics Tracking code (see step 2 from above) and add that after the end of your SnapEngage code.
Now, comment out the last line of the Google Analytics Tracking code - ga('send', 'pageview');
Your final snippet for that tag should look something like this (the sample below provides both types of Google Analytics in the code):
If you notice custom events are not showing in the GA reports, there is a way to verify that the events are not sent from the browser correctly - see in a debugger (Chrome developer tools or FireBug) that the “utmac” parameter is sent as something like “UA-XXXX-X”, instead of the real Google Analytics account id.
A solution is to set a Tracker Name (in this case in the advanced settings):
Feel free to chat with us with any questions!
Published January 12, 2012