-
Notifications
You must be signed in to change notification settings - Fork 0
/
anonymous_audiences.html
39 lines (27 loc) · 1.89 KB
/
anonymous_audiences.html
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
<!DOCTYPE html>
<html>
<head>
<title>Anonymous Users to FB, Google and Twitter</title>
<script>
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t,e){var n=document.createElement("script");n.type="text/javascript";n.async=!0;n.src="https://cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.1.0";
analytics.load("f0mkFrd38lR8LW97t73odW9VkiQP532m", { integrations: { All: false, 'Google Analytics': true, 'Facebook Pixel': true, 'Twitter': true, 'Segment.io': true } });
}}();
// WHen Segment is Ready, get the anonymousId and fetch all other traits from Personas
analytics.ready(function() {
const anonymousId = analytics.user().anonymousId();
const Http = new XMLHttpRequest();
const url= `http://localhost:3000/?anonymousId=${anonymousId}`;
Http.open("GET", url);
Http.send();
Http.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200){
document.write(Http.responseText);
}
};
});
</script>
</head>
<body>
<h1>This page tests sending anonymous audience data to FB, Google and Twitter</h1>
</body>
</html>