Created
September 24, 2009 08:32
-
-
Save skylar/192608 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Returns the URL to call piwik.php, | |
| * with the standard parameters (plugins, resolution, url, referer, etc.) | |
| */ | |
| function getRequest() { | |
| var i, now, request; | |
| now = new Date(); | |
| request = 'idsite=' + configTrackerSiteId + | |
| '&url=' + escapeWrapper(documentAlias.location.href) + | |
| '&res=' + screenAlias.width + 'x' + screenAlias.height + | |
| '&h=' + now.getHours() + '&m=' + now.getMinutes() + '&s=' + now.getSeconds() + | |
| '&cookie=' + browserHasCookies + | |
| '&urlref=' + escapeWrapper(pageReferrer) + | |
| '&rand=' + Math.random(); | |
| // plugin data | |
| for (i in pluginMap) { | |
| request += '&' + pluginMap[i][0] + '=' + pluginMap[i][2]; | |
| } | |
| request = configTrackerUrl + '?' + request; | |
| return request; | |
| } | |
| /* | |
| * Get the web bug image (transparent single pixel, 1x1, image) to log visit in Piwik | |
| */ | |
| function getWebBug() { | |
| var request = getRequest(); | |
| request += '&action_name=' + escapeWrapper(configTitle); // refs #530; | |
| // encode custom data | |
| if (isDefined(configCustomData)) { | |
| request += '&data=' + escapeWrapper(stringify(configCustomData)); | |
| } | |
| request += executePluginMethod('log'); | |
| getImage(request, configTrackerPause); | |
| } | |
| /* | |
| * Log the goal with the server | |
| */ | |
| function logGoal(idGoal, customRevenue, customData) { | |
| var request = getRequest(); | |
| request += '&idgoal=' + idGoal; | |
| if (isDefined(customRevenue) && customRevenue !== null) { | |
| request += '&revenue=' + customRevenue; | |
| } | |
| // encode custom data | |
| if (isDefined(customData)) { | |
| if (customData !== null) { | |
| request += '&data=' + escapeWrapper(stringify(customData)); | |
| } | |
| } else if (isDefined(configCustomData)) { | |
| request += '&data=' + escapeWrapper(stringify(configCustomData)); | |
| } | |
| request += executePluginMethod('goal'); | |
| getImage(request, configTrackerPause); | |
| } | |
| /* | |
| * Log the click with the server | |
| */ | |
| function logClick(url, linkType, customData) { | |
| var request; | |
| request = 'idsite=' + configTrackerSiteId + | |
| '&' + linkType + '=' + escapeWrapper(url) + | |
| '&rand=' + Math.random() + | |
| '&redirect=0'; | |
| // encode custom data | |
| if (isDefined(customData)) { | |
| if (customData !== null) { | |
| request += '&data=' + escapeWrapper(stringify(customData)); | |
| } | |
| } else if (isDefined(configCustomData)) { | |
| request += '&data=' + escapeWrapper(stringify(configCustomData)); | |
| } | |
| request += executePluginMethod('click'); | |
| request = configTrackerUrl + '?' + request; | |
| getImage(request, configTrackerPause); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment