-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatsby-browser.js
executable file
·57 lines (46 loc) · 1.57 KB
/
gatsby-browser.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
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
// You can delete this file if you're not using it
// console.log("************** GA Defined : ", (typeof window.ga === 'function'));
// console.log("************** window.dataLayer : ", window.dataLayer);
/*
// Adjust the GA snippet on site
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-77246883-1', {
'linker': {
'domains': ['rezdy.com']
}
})
// Integrate code into every page
function check_ga() {
if (typeof window.ga==='function') {
ga(function(tracker) {
// When using Google Tag Manager there is no default tracker
if (tracker==undefined) {
tracker=ga.getAll()[0];
}
// Gets the client ID of the default tracker.
var gaClientId=tracker.get('clientId');
// Gets all iframes on the page
var rezdyElements=document.getElementsByClassName('rezdy');
for (var i=0; i < rezdyElements.length; i++) {
if (rezdyElements[i].contentWindow) {
// Wait for Iframe receiver to be loaded
rezdyElements[i].addEventListener("load", function() {
// Make sure you use your own company Alias here
this.contentWindow.postMessage(gaClientId, 'https://sailinginparadise.rezdy.com');
});
}
}
});
} else {
setTimeout(function(){check_ga();},500);
}
}
check_ga();
*/