We know, Google Analytics is complicated. Depending on when their tracking code was added to your site, one of their variation was used: Classic (ga.js), Universal Tracking, gtag.js or more recently GA4.
For all installations, you need to use the
hooks feature where callback functions are defined and triggered when their respective events happen:
Pick your flavor: The codes below displays a sample event handler that sends a conversion event for the Play action to Google Analytics using all 4 possible methods.
Documentation: https://developers.google.com/analytics/devguides/collection/ga4/events Help Center Articles:
gtag.js snippets for a Universal Analytics property and for a Google Analytics 4 property are fundamentally the same.
How do I know which version of the Google Analytics tracking code is on my website? To find out which version of Google Analytics tracking you’re using:
- Go to your website.
- Right click and select View page source.
- Press ctrl (cmd) + F to open the find menu.
- Search for the various tags.
- Search for ga.js. If you find a reference to this you are using the Classic tracking.
- Search for analytics.js. If you find a reference to this you are using Universal tracking.
- Search for gtag.js. If you find a reference to this you are using the gtag.js tracking code.
Ready to Grow Your Business?Start using Video Donut today.
Add a stories-style video to your website to boost engagement and conversions.Sign up for Free