-
Notifications
You must be signed in to change notification settings - Fork 10
Google Analytics
Mehmood Asghar edited this page Sep 24, 2020
·
1 revision
To add Google Analytics to NADA, paste the code in the theme footer. Replace UA-YOUR-CODE
with your own Google Analytics code.
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-YOUR-CODE"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-YOUR-CODE');
$(function() {
$(document).ajaxSend(function(event, request, settings) {
gtag('event', 'page_view', {
page_path: settings.url
})
});
//track file downloads
$('.resources .download').on('click', function() {
gtag('event', 'download', {
'event_label': $(this).attr("title"),
'event_category': $(this).attr("href"),
'non_interaction': true
});
});
});