forked from pytorch/pytorch.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack-events.js
89 lines (75 loc) · 2.64 KB
/
track-events.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
var trackEvents = {
recordClick: function(eventCategory, eventLabel) {
if (typeof ga == "function") {
var gaEventObject = {
eventCategory: eventCategory,
eventAction: "click",
eventLabel: eventLabel
};
ga('send', 'event', gaEventObject);
if (eventCategory == "Quick Start Module - Cloud Platforms") {
ga('newCampaignTracker.send', 'event', gaEventObject);
}
}
if (typeof fbq === "function") {
fbq("trackCustom", eventCategory, {
target: eventLabel
});
}
},
bind: function() {
// Clicks on the main menu
$(".main-menu ul li a").on("click", function() {
trackEvents.recordClick("Global Nav", $(this).text());
return true;
});
// Clicks on Resource cards
$(".resource-card a").on("click", function() {
trackEvents.recordClick("Resource Card", $(this).find("h4").text());
return true;
});
// Clicks on Ecosystem Project cards
$(".ecosystem-card a").on("click", function() {
trackEvents.recordClick("Ecosystem Project Card", $(this).find("h4").text());
return true;
});
// Clicks on 'Get Started' call to action buttons
$("[data-cta='get-started']").on("click", function() {
trackEvents.recordClick("Get Started CTA", $(this).text());
return true;
});
// Clicks on Cloud Platforms in Quick Start Module
$(".cloud-option").on("click", function() {
var platformName = $.trim($(this).find(".cloud-option-body").text());
trackEvents.recordClick("Quick Start Module - Cloud Platforms", platformName);
});
// Clicks on Cloud Platform Services in Quick Start Module
$(".cloud-option ul li a").on("click", function() {
var platformName = $.trim(
$(this).
closest("[data-toggle='cloud-dropdown']").
find(".cloud-option-body").
text()
);
var serviceName = $.trim($(this).text());
trackEvents.recordClick(
"Quick Start Module - Cloud Platforms",
platformName + " - " + serviceName
);
return true;
});
// Clicks on options in Quick Start - Locally
$(".quick-start-module .row .option").on("click", function() {
var selectedOption = $.trim($(this).text());
var rowIndex = $(this).closest(".row").index();
var selectedCategory = $(".quick-start-module .headings .title-block").
eq(rowIndex).
find(".option-text").
text();
trackEvents.recordClick(
"Quick Start Module - Local Install",
selectedCategory + ": " + selectedOption
)
})
}
};