-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathga-function.js
More file actions
45 lines (40 loc) · 1.22 KB
/
Copy pathga-function.js
File metadata and controls
45 lines (40 loc) · 1.22 KB
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
function Ga(gaSelector) {
this.gaItems = [].slice.call(document.querySelectorAll(gaSelector));
this.eventClick = () => {
this.gaItems.forEach(gaItem => {
if (gaItem.dataset.gaEvca && gaItem.dataset.gaEvac && gaItem.dataset.gaEvlb) {
gaItem.addEventListener('click', function () {
ga('send', {
hitType: 'event',
eventCategory: gaItem.dataset.gaEvca,
eventAction: gaItem.dataset.gaEvac,
eventLabel: gaItem.dataset.gaEvlb
});
if (gaItem.dataset.gaEvca != 'Cadastro') {
fbq('track', 'ViewContent', {
content_name: gaItem.dataset.gaEvca,
content_category: gaItem.dataset.gaEvac,
content_type: gaItem.dataset.gaEvlb,
referrer: document.referrer,
userAgent: navigator.userAgent,
language: navigator.language
});
} else {
fbq('track', 'Lead', {
content_name: gaItem.dataset.gaEvca,
content_type: gaItem.dataset.gaEvac,
content_name: gaItem.dataset.gaEvlb,
referrer: document.referrer,
userAgent: navigator.userAgent,
language: navigator.language
});
}
});
} else {
return;
}
});
};
this.eventClick();
}
new Ga('[data-ga]');