Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Merge pull request #2 from theonion/try-catch-track-event
Browse files Browse the repository at this point in the history
wrapped event trackers in try/catch blocks
  • Loading branch information
vforgione committed Sep 2, 2015
2 parents dafa39a + f04aa17 commit e38c524
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bower_components
node_modules
.idea/
22 changes: 19 additions & 3 deletions src/analytics-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ var AnalyticsManager = {
},

comscoreBeacon: function() {
COMSCORE.beacon({ c1: 2, c2: 6036328, c3: "", c4: "", c5: "", c6: "", c15: "" });
if (window.COMSCORE) {
COMSCORE.beacon({ c1: 2, c2: 6036328, c3: "", c4: "", c5: "", c6: "", c15: "" });
} else {
console.warn('COMSCORE not available');
}
},

sendComscorePixel: function(freshPage, title) {
Expand All @@ -52,7 +56,11 @@ var AnalyticsManager = {

sendQuantcastPixel: function(freshPage) {
if (!freshPage) {
_qevents.push({ qacct:"p-39FYaAGOYli_-", 'event': "refresh" });
if (window._qevents) {
_qevents.push({ qacct:"p-39FYaAGOYli_-", 'event': "refresh" });
} else {
console.warn('_qevents not available');
}
}
},

Expand All @@ -65,14 +73,22 @@ var AnalyticsManager = {
}
},

sendIngestPixel: function () {
if (window.Ingest) {
Ingest.sendEvent();
} else {
console.warn('Ingest not available');
}
},

trackPageView: function(freshPage, optionalTitle) {
var path = window.location.pathname;
if (this.trackedPaths.indexOf(path) < 0) {
ga('send', 'pageview', path);
ga('adTracker.send', 'pageview', 'theonion' + path);
this.sendQuantcastPixel(freshPage);
this.sendComscorePixel(freshPage, optionalTitle);
Ingest.sendEvent();
this.sendIngestPixel();
if (!freshPage) {
this.sendChartbeatEvent(optionalTitle);
}
Expand Down

0 comments on commit e38c524

Please sign in to comment.