Skip to content

Commit 4d6bc0c

Browse files
committed
Fix broken analytics stopping page transitions
Change-Id: If1ef4cff33e92181ec8eab9a79c8e4fa93ad247c
1 parent b193671 commit 4d6bc0c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

scripts/tutorialPage.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// -*- mode: javascript; js-indent-offset: 2; -*-
1+
// -*- mode: javascript; js-indent-level: 2; -*-
22
// Copyright © 2017-2019 Massachusetts Institute of Technology, All rights reserved.
33
// Released under the Apache License, Version 2.0
44
// http://www.apache.org/licenses/LICENSE-2.0
@@ -295,8 +295,14 @@ $(document).ready(function() {
295295

296296
sendAnalyticsEvent = function(eventObject) {
297297
if(document.getElementById("hasAnalytics") && document.getElementById("hasAnalytics").innerHTML === "1") {
298-
ga('send', eventObject);
299-
//console.log(eventObject);
298+
if (gtag) {
299+
try {
300+
var eventAction = eventObject.eventAction || 'custom_event';
301+
gtag('event', eventAction, eventObject);
302+
} catch (e) {
303+
// Throwing an error here breaks page transitions.
304+
}
305+
}
300306
}
301307
};
302308
enlargeVideo = function (youtubeid) {

0 commit comments

Comments
 (0)