Skip to content
Permalink
Browse files

Send GA ping on browser startup

  • Loading branch information
schalkneethling committed Apr 24, 2017
1 parent 7dde0b4 commit db4d6c8726c89a5d6a241c1b1065827b525c5baf
Showing with 33 additions and 5 deletions.
  1. +2 −0 index.js
  2. +30 −4 lib/ga-utils.js
  3. +1 −1 package.json
@@ -51,6 +51,8 @@ exports.main = function() {

setUpTestEnv();

gaUtils.sendStartupGAPing();

// if destroyAddon is true
if (detroyAddon) {
// destroy the pageMod as the tour is complete.
@@ -6,6 +6,10 @@ let timers = require('sdk/timers');
let { storageManager } = require('./storage-manager.js');
let { variations } = require('./variations.js');

const clientId = '35009a79-1a05-49d7-b876-2b884d0f825b';
const hitType = 'event';
const trackingId = 'UA-36116321-22';

exports.gaUtils = {
/**
* Gathers and returns data for the current event
@@ -48,18 +52,18 @@ exports.gaUtils = {
url: 'https://www.google-analytics.com/collect',
content: {
v: 1,
t: 'event',
t: hitType,
ec: 'Addon Interactions',
ea: eventData.step,
el: label,
cid: '35009a79-1a05-49d7-b876-2b884d0f825b',
cid: clientId,
cd3: eventData.contentVariation,
cd4: eventData.topic,
cd5: module.exports.gaUtils.impressionCount(),
tid: 'UA-36116321-22'
tid: trackingId
},
onComplete: function(response) {
console.error('Response from GA', response.status);
console.error('Response for post from GA', response.status);
}
});

@@ -68,5 +72,27 @@ exports.gaUtils = {
timers.setTimeout(function() {
gaRequest.post();
}, 5000);
},
/**
* Send a ping to GA on each startup of the browser
*/
sendStartupGAPing: function() {
let gaRequest = Request({
url: 'https://www.google-analytics.com/collect',
content: {
v: 1,
t: hitType,
ec: 'Firefox Interactions',
ea: 'Start Browser',
cid: clientId,
cd3: storageManager.get('variation'),
tid: trackingId
},
onComplete: function(response) {
console.error('Response for sendStartupGAPing from GA', response.status);
}
});

gaRequest.post();
}
};
@@ -1,7 +1,7 @@
{
"title": "Firefox OnBoard",
"name": "onboard-v1",
"version": "1.0.4",
"version": "1.0.5",
"description": "The Mozilla Firefox Onboarding Experiment",
"homepage": "https://github.com/mozilla/onaboard",
"repository": "https://github.com/mozilla/onaboard",

0 comments on commit db4d6c8

Please sign in to comment.