This article applies to Higher Logic Vanilla (Vanilla) customers looking to use the native tracking code of Google Analytics without Google Tag Manager. It also applies to those using our Knowledge Base (KB) product.
📝 NOTE: Adding tracking code directly to a theme means you should be using the theme for mobile and non-mobile visitors.
Retrieve your Tracking Code
Get your tracking code from Google Analytics from your Google Analytics console in the Tracking Code area.
Add your Tracking Code to Vanilla
1. Access the Dashboard.
2. Navigate to the Theme Editor and access the JavaScript tab.
3. Copy the code from below and paste it on the JavaScript tab.
📝 NOTE: We are using the onVanillaReady function.
onVanillaReady(function () {
/**
* Google Tracker
*/
addScript("https://www.googletagmanager.com/gtag/js?id=UA-xxxxxx-xx");
})
function addScript(src) {
var s = document.createElement('script');
s.setAttribute('src', src);
s.async = true;
s.defer = true;
document.body.appendChild(s);
}
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxx-xx');
4. Replace both instances of UA-xxxxxx-xx with your own Google Analytics account.
5. Click Save in the upper right and return to the Dashboard.
Allow-list Google Analytics
Now you have to add the Google sites as trusted domains to ensure that Google Analytics traffic can be read.
1. In the Dashboard, navigate to Settings > Security.
2. In the Content Security Domains field, add:
*.googletagmanager.com
*.google-analytics.com
3. Scroll down and click Save.
Google Tag Manager
If you plan to implement Google Tag Manager, see: