forked from matjaztrontelj/gaNoCookie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.html
40 lines (34 loc) · 1.92 KB
/
example.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
40
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
...
<!-- Include the ganc code just before the closing body tag -->
<script>
//path to the script that will generate and return the user id
gancGetUidUrl = '/ganc/ga_no_cookie_uid.php';
//just copy and paste this. You only need to edit the url in the last line of this code paragraph
(function(i,s,o,g,r,a,m){i['GoogleNoCookieAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','/ganc/ga_no_cookie.php?v=3','ganc');
//Only edit the url in the above line. Instead of including JS file via PHP script, you could also include ga_no_cookie_min.js directly and set up caching with webserver instructions. Use ?v=1234... to force cache update if you change the JS file or upgrade to a new version of this library.
//id of dom element that will hold opt-in and opt-out links (optional)
ganc_status_eid = "ganc_status";
//text for the link if ganc is on
ganc_status_on = "Turn off anonymous usage statistics collection.";
//text for the link if ganc is off
ganc_status_off = "Turn on anonymous usage statistics collection";
//Setup tracker id and start sending hits. Enter your tracking id.
ganc('create', 'UA-123456-1', '');
//Send page view
ganc('send', 'pageview');
//Optionally, send events. Category and Action are required.
ganc('send', 'event', 'EVENT_CATEGORY', 'EVENT_ACTION', 'EVENT_LABEL');
//That's it! Check GA Real time view to see if it is working. Note: real time mode sometimes shows doubled events and returning visitors appear only after a day or so of usage.
</script>
</body>
</html>