This repository has been archived by the owner on Dec 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplittrack.js
208 lines (168 loc) · 5.72 KB
/
splittrack.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
// Copyright (c)2008 Site Meter, Inc.
// <![CDATA[
var protocol = "http";
var cookiesEnabled = "1";
if ( document.cookie == "" ) {
document.cookie = "cookies=yes";
if ( document.cookie == "" )
cookiesEnabled = "0";
else
document.cookie = "";
}
var SiteMeter2 =
{
init:function( newSiteID ) {
SiteMeter2.siteID = newSiteID;
SiteMeter2.clickImage = document.createElement( "img" );
if ( ( typeof( g_lastSiteID2 ) != 'undefined' ) && ( g_lastSiteID2 == newSiteID ) )
return;
SiteMeter2.trackPageLoad( );
if ( detectClicks )
SiteMeter2.addEvent( window, "load", SiteMeter2.trackOutClicks );
},
trackOutClicks:function( ) {
for( var i = 0; i < document.links.length; i++ ) {
SiteMeter2.addEvent( document.links[i], "click", SiteMeter2.onClick );
}
},
trackPageLoad:function( ) {
var newImage = document.createElement( "img" );
newImage.width = 0;
newImage.height = 0;
var dateToday = new Date();
var timeZoneOffset = ( typeof( dateToday.getTimezoneOffset )!= 'undefined' ) ? dateToday.getTimezoneOffset( ) : '';
var referrer = SiteMeter2.getReferral( );
var trackImage = protocol + "://tr.sitemeter.com/track?site=" + SiteMeter2.siteID;
trackImage += "&u=" + encodeURIComponent( window.location.href );
trackImage += "&r=" + referrer;
trackImage += "&jsid=IU1o0NGf5CrkWiAEL4pe";
trackImage += "&w=" + window.screen.width;
trackImage += "&h=" + window.screen.height;
trackImage += "&clr=" + window.screen.colorDepth;
trackImage += "&tzo=" + timeZoneOffset;
trackImage += "&lang=" + encodeURIComponent( navigator.language ? navigator.language : navigator.userLanguage );
trackImage += "&js=" + jsVersion;
trackImage += "&ck=" + cookiesEnabled;
trackImage += "&flv=" + encodeURIComponent( flashVer );
trackImage += "&ni=1&rnd=" + Math.random( );
newImage.src = trackImage;
var scriptRef = SiteMeter2.getScriptElement( );
var parentOfScript = SiteMeter2.getParent( scriptRef );
if ( parentOfScript )
parentOfScript.appendChild( newImage );
},
logEvent:function( sEvent, sText, sURL ) {
if ( document.images && !SiteMeter2.isLocalURL( sURL ) && SiteMeter2.clickImage )
{
var clickImageURL = protocol + "://tr.sitemeter.com/track?site=" + SiteMeter2.siteID;
clickImageURL += "&jsid=IU1o0NGf5CrkWiAEL4pe";
clickImageURL += "&e=" + sEvent;
clickImageURL += "&l=" + encodeURIComponent( sURL );
clickImageURL += "&t=" + encodeURIComponent( sText );
clickImageURL += "&u="+ encodeURIComponent( window.location.href );
SiteMeter2.clickImage.src = clickImageURL;
}
},
trimFragment:function( sString ) {
var fragIndex = sString.indexOf( "#" );
return ( fragIndex > 0 ? sString.substring( 0, fragIndex ) : sString );
},
isLocalURL:function( sURL ) {
return ( SiteMeter2.trimFragment( document.location.href ) == SiteMeter2.trimFragment( sURL ) );
},
getReferral:function( ) {
var sRef = "";
var g_d = document;
if ( typeof( g_frames ) != "undefined" && g_frames )
sRef = top.document.referrer;
if ( ( sRef == "" ) || ( sRef == "[unknown origin]" ) || ( sRef == "unknown") || (sRef == "undefined" ) ) {
if ( document["parent"] != null )
if ( parent["document"] != null ) // ACCESS ERROR HERE!
if ( parent.document["referrer"] != null )
if ( typeof( parent.document ) == "object" )
sRef = parent.document.referrer;
}
if ( ( sRef == "" ) || ( sRef == "[unknown origin]" ) || ( sRef == "unknown") || (sRef == "undefined" ) ) {
if ( g_d["referrer"] != null )
sRef = g_d["referrer"];
}
if ( ( sRef == "" ) || ( sRef == "[unknown origin]" ) || ( sRef == "unknown") || (sRef == "undefined" ) )
sRef = "";
return encodeURIComponent( sRef );
},
getParent:function( e ) {
if ( !e )
return null;
if ( e.parentNode )
return e.parentNode;
else if ( e.parentElement )
return e.parentElement;
else
return null;
},
getScriptElement:function( ) {
var refScript = null;
refScript = document.getElementById( "SiteMeter2Script" );
if ( refScript )
return refScript;
var pageScripts = document.getElementsByTagName( "script" );
for( var i = 0; i < pageScripts.length; i++ ) {
if ( pageScripts[i].src )
{
var sSource = pageScripts[i].src.toLowerCase( );
if ( sSource.indexOf( "site=" + SiteMeter2.siteID ) > 0 )
return pageScripts[i];
}
}
return null;
},
getTarget:function( e ) {
var targ = null;
if ( !e )
e = window.event;
if ( e.target )
targ = e.target;
else if ( e.srcElement )
targ = e.srcElement;
if ( targ.nodeType && targ.nodeType == 3 ) // Safari bug
targ = targ.parentNode;
return targ;
},
elementText:function( e ) {
do {
var sText = ( e.text )? e.text : e.innerText;
if ( sText )
return sText.substr( 0,100 );
if ( e.alt )
return e.alt;
if ( e.src )
return e.src;
e = SiteMeter2.getParent( e );
} while ( e );
return "";
},
elementURL:function( e ) {
do {
if ( ( e.href ) && ( e.nodeName.toUpperCase( ) == 'A') )
return e.href;
e = SiteMeter2.getParent( e );
} while ( e );
return "";
},
onClick:function( e ) {
var target = SiteMeter2.getTarget( e );
SiteMeter2.logEvent( "click", SiteMeter2.elementText( target ), SiteMeter2.elementURL( target ) );
},
addEvent:function( obj, sEvent, func ) {
if ( obj.addEventListener )
obj.addEventListener( sEvent, func, false );
else if ( obj.attachEvent )
obj.attachEvent( "on" + sEvent, func );
else
return false;
return true;
}
}
SiteMeter2.init( siteID );
var g_lastSiteID2 = siteID;
// ]]>