Get started with autotrack CDN
Apache-2.0 licensed
Autotrack: library automatically sending Google Analytics events without manual coding.
Tags:- analytics
- analyticsjs
- auto
Stable version
Copied!
How to start using autotrack CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with autotrack CDN - cdnhub.io</title>
<script src="https://cdn.cdnhub.io/autotrack/2.4.1/autotrack.js"></script>
</head>
<body>
<button id="myButton">Click me</button>
<script>
// Initialize Autotrack
window.dataLayer = window.dataLayer || [];
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-12345678-1', 'auto');
// Initialize Autotrack with Google Analytics
autotrack.push(['config', { trackingId: 'UA-12345678-1' }]);
// Attach Autotrack to elements
autotrack.push(['trackElement', document.querySelector('#myButton')]);
// Attach Autotrack to links
autotrack.push(['trackClick', document.querySelectorAll('a')]);
</script>
</body>
</html>
Copied!
Copied!