Tracking Script: Replace UA ID with clients Analytics account ID – Placed inside <head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX-Y"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config','UA-XXXXX-Y');
</script>Event Tracking: Further Documentation
gtag('event', 'action', {
'event_category': 'category'
});Example Event:
<script>
jQuery('a[href*="tel:"]').on('click', function(){
gtag('event', 'click', {
'event_category': 'phone-number'
});
});
</script>Routing Example Event:
It is also possible to specify the UA ID you wish to send the event to, using the send_to argument
(For use when the site is using multiple Gtag.js Instances)
<script>
jQuery('a[href*="tel:"]').on('click', function(){
gtag('event', 'click', {
'send_to': 'UA-xxxxxxxx-x',
'event_category': 'phone-number'
});
});
</script>