Skip to content

Commit

Permalink
Merge pull request #47 from chris1312/master
Browse files Browse the repository at this point in the history
Invalid source URL for Google Analytics
  • Loading branch information
Jurian Sluiman committed Dec 15, 2014
2 parents 8afb211 + 4be8b27 commit 26b3477
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/SlmGoogleAnalytics/View/Helper/Script/Gajs.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ public function getCode()
protected function getLoadScript()
{
$script = 'google-analytics.com/ga.js';
$scheme = "'https://ssl.' : 'http://www.'";
if (true === $this->tracker->getEnableDisplayAdvertising()) {
$script = 'stats.g.doubleclick.net/dc.js';
$scheme = "'https://' : 'http://'";
}

return <<<SCRIPT
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + '$script';
ga.src = ('https:' == document.location.protocol ? $scheme) + '$script';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();\n
SCRIPT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testHelperLoadsFileFromGoogle()
$expected = <<<SCRIPT
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'google-analytics.com/ga.js';
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);
})();\n
SCRIPT;
Expand Down

0 comments on commit 26b3477

Please sign in to comment.