-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathgraphAnalytics.js
39 lines (25 loc) · 1.6 KB
/
graphAnalytics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
let analyticsSite = "Generic Graph site", // Site name for attributing analytics events to your site
logAnalytics = true; // If true, events are logged in console
// *************************************************************
// Functions to fire events
// *************************************************************
// For events related to specific phones, e.g. when a phone is displayed
function pushPhoneTag(eventName, p, trigger) {
let eventTrigger = trigger ? trigger : "user",
phoneBrand = p.dispBrand ? p.dispBrand : "Target",
phoneModel = p.dispName,
value = 1;
// Write function here to push event with the values described above
if (logAnalytics) { console.log("Event: "+ eventName +"\nTrigger: "+ eventTrigger +"\nSite: "+ analyticsSite +"\nPhone: "+ phoneBrand +" "+ phoneModel); }
}
// For events not related to a specific phone, e.g. user clicked screenshot button
function pushEventTag(eventName, targetWindow, trigger) {
let eventTrigger = trigger ? trigger : "user",
url = targetWindow.location.href,
par = "?share=",
value = 1,
activePhones = url.includes(par) ? decodeURI(url.replace(/_/g," ").split(par).pop().replace(/,/g, ", ")) : "null";
// Write function here to push event with the values described above
if (logAnalytics) { console.log("Event: "+ eventName +"\nTrigger: "+ eventTrigger +"\nSite name: "+ analyticsSite +"\nActive: "+activePhones); }
}
if (logAnalytics) { console.log("... Analytics initialized ... "); }