summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhass2008-04-23 20:29:46 (GMT)
committer hass2008-04-23 20:29:46 (GMT)
commitec17d4dc1a8912977deb97740a85aca8b8eb9e39 (patch)
tree6782eeab42578f635f799a460fe92c5aff80c47a
parent4f04daa2e1d9e256a42c8b96c1ea2347b51c30c3 (diff)
* Make ga.js output 100% same like standard google code.
* Remove server based HTTPS detection that may break with Load Balancer SSL Accelerators * urchin.js must use the same JS output and may fail to verify (untested)
-rw-r--r--googleanalytics.module13
1 files changed, 4 insertions, 9 deletions
diff --git a/googleanalytics.module b/googleanalytics.module
index 4b4b3f1..1c9975a 100644
--- a/googleanalytics.module
+++ b/googleanalytics.module
@@ -50,25 +50,20 @@ function googleanalytics_footer($main = 0) {
// 3. Check if we should track the currently active user's role.
if (!empty($id) && _googleanalytics_visibility() && _googleanalytics_track($user)) {
- // Are we on a secure page?
- $prefix = '://www';
- if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) {
- $prefix = 's://ssl';
- }
-
// Use the old version of Google Analytics?
$legacy_version = variable_get('googleanalytics_legacy_version', TRUE);
$scope = variable_get('googleanalytics_js_scope', 'footer');
// Should a local cached copy of urchin.js or ga.js be used?
$js_file = ($legacy_version) ? 'urchin.js' : 'ga.js';
- $url = 'http'. $prefix .'.google-analytics.com/'. $js_file;
+ $url = 'http://www.google-analytics.com/'. $js_file;
if (variable_get('googleanalytics_cache', 0) && (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) && $source = _googleanalytics_cache($url)) {
drupal_add_js($source, 'module', $scope);
}
else {
- $script = 'document.write(unescape("%3Cscript src=\''. $url .'\' type=\'text/javascript\'%3E%3C/script%3E"));';
+ $script = 'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");';
+ $script .= 'document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/'. $js_file .'\' type=\'text/javascript\'%3E%3C/script%3E"));';
drupal_add_js($script, 'inline', $scope);
}
@@ -425,7 +420,7 @@ function googleanalytics_cron() {
* @return mixed
* The path to the local javascript file on success, boolean FALSE on failure.
*/
-function _googleanalytics_cache($location = 'http://www.google-analytics.com/urchin.js') {
+function _googleanalytics_cache($location) {
$directory = file_directory_path() .'/googleanalytics';
$file_destination = $directory .'/'. basename($location);
if (!file_exists($file_destination)) {