Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Send GA ping on browser startup
Browse files Browse the repository at this point in the history
  • Loading branch information
schalkneethling committed Apr 24, 2017
1 parent 7dde0b4 commit db4d6c8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ exports.main = function() {

setUpTestEnv();

gaUtils.sendStartupGAPing();

// if destroyAddon is true
if (detroyAddon) {
// destroy the pageMod as the tour is complete.
Expand Down
34 changes: 30 additions & 4 deletions lib/ga-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
});

Expand All @@ -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();
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit db4d6c8

Please sign in to comment.