Analytics for link tracking.

Does it work?
This commit is contained in:
Justin Hsu 2017-09-30 14:40:59 +01:00
parent 2f6065a267
commit 7477f8eb7d
2 changed files with 13 additions and 4 deletions

View File

@ -15,13 +15,13 @@
$month$ $year$.</br>
$endif$
$if(url)$
[<a href="$url$">Paper</a>]
[<a href="$url$" onclick="trackLink('@$identifier$:link','$url$'); return false;">Paper</a>]
$endif$
$if(slides)$
[<a href="$slides$">Slides</a>]
[<a href="$slides$" onclick="trackLink('@$identifier$:slides','$url$'); return false;">Slides</a>]
$endif$
$if(poster)$
[<a href="$poster$">Poster</a>]
[<a href="$poster$" onclick="trackLink('@$identifier$:poster','$url$'); return false;">Poster</a>]
$endif$
<br>
$if(note)$

View File

@ -15,8 +15,17 @@ type='text/css'>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)};
gtag('js', new Date());
gtag('config', 'UA-33267683-1');
var trackLink = function(label,url) {
gtag('event', 'click', {
'event_category': 'link',
'event_label': label,
'event_action': url,
'transport_type': 'beacon',
'event_callback': function(){document.location = url;}
});
}
</script>
</head>