From 7477f8eb7d9ee82ed39cb6833f42500a8f32effb Mon Sep 17 00:00:00 2001 From: Justin Hsu Date: Sat, 30 Sep 2017 14:40:59 +0100 Subject: [PATCH] Analytics for link tracking. Does it work? --- templates/bibitemtpl.html | 6 +++--- templates/main.html | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/templates/bibitemtpl.html b/templates/bibitemtpl.html index f8b6ea1..905fb7d 100644 --- a/templates/bibitemtpl.html +++ b/templates/bibitemtpl.html @@ -15,13 +15,13 @@ $month$ $year$.
$endif$ $if(url)$ - [Paper] + [Paper] $endif$ $if(slides)$ - [Slides] + [Slides] $endif$ $if(poster)$ - [Poster] + [Poster] $endif$
$if(note)$ diff --git a/templates/main.html b/templates/main.html index 41f6b2f..cb7b05c 100644 --- a/templates/main.html +++ b/templates/main.html @@ -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;} + }); +}