-
Notifications
You must be signed in to change notification settings - Fork 7
/
example_ga.html
57 lines (49 loc) · 2.29 KB
/
example_ga.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<title></title>
</head>
<body>
<!-- Include both these scripts or copy them into your main JavaScript file -->
<!--[if lt IE 10]>
<script type="text/javascript" src="http://veddecode.opensource.dpo.org.uk/js/base64-1.1.min.js"></script>
<![endif]-->
<script type="text/javascript" src="http://veddecode.opensource.dpo.org.uk/js/ved_analytics-1.1.min.js"></script>
<script type="text/javascript">
// Use this code with (the old) version of Analytics (ga.js)
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']); // Your Analytics property ID
// The custom variable code needs to go *before* _trackPageview
(function(w) {
var customVars = [
{ slot: 1, name: 'Google link index', v: 'linkIndex' },
{ slot: 2, name: 'Google link type', v: 'linkType' },
{ slot: 3, name: 'Google result position', v: 'resultPosition' },
{ slot: 4, name: 'Google sub-result position', v: 'subResultPosition' },
{ slot: 5, name: 'Google page', v: 'page' }
];
if (w.VedDecode && w.VedDecode.ved) {
for (var i = 0, val; i < customVars.length; ++i) {
val = w.VedDecode[customVars[i].v];
_gaq.push([
'_setCustomVar',
customVars[i].slot,
customVars[i].name,
val ? val + '' : '(not set)',
2 // session scope
]);
}
}
})(window);
_gaq.push(['_trackPageview']); // Record the pageview last of all
// Standard Google code to load ga.js
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>