Permalink
Browse files

[ANALYTICS] Support to change the Javascript Source url and protocol …

…- so it can be replaced with Double Clicks beta remarketing service - Yay
  • Loading branch information...
1 parent 2778d84 commit 10a204c17ab577689953e23bc3f8e0960aedf614 @matthewfitz matthewfitz committed Jan 5, 2012
@@ -68,6 +68,15 @@ private function analyticsLoad(array $configs, ContainerBuilder $container)
if (isset($config['whitelist'])) {
$container->setParameter('google.analytics.whitelist', $config['whitelist']);
}
+ if (isset($config['js_source_https'])) {
+ $container->setParameter('google.analytics.js_source_https', $config['js_source_https']);
+ }
+ if (isset($config['js_source_http'])) {
+ $container->setParameter('google.analytics.js_source_http', $config['js_source_http']);
+ }
+ if (isset($config['js_source_endpoint'])) {
+ $container->setParameter('google.analytics.js_source_endpoint', $config['js_source_endpoint']);
+ }
}
}
View
@@ -9,10 +9,16 @@
class AnalyticsHelper extends Helper
{
private $analytics;
+ private $sourceHttps;
+ private $sourceHttp;
+ private $sourceEndpoint;
- public function __construct(Analytics $analytics)
+ public function __construct(Analytics $analytics, $sourceHttps, $sourceHttp, $sourceEndpoint)
{
$this->analytics = $analytics;
+ $this->sourceHttps = $sourceHttps;
+ $this->sourceHttp = $sourceHttp;
+ $this->sourceEndpoint = $sourceEndpoint;
}
public function getAllowHash($trackerKey)
@@ -85,6 +91,21 @@ public function getPageViewQueue()
return $this->analytics->getPageViewQueue();
}
+ public function getSourceHttps()
+ {
+ return $this->sourceHttps;
+ }
+
+ public function getSourceHttp()
+ {
+ return $this->sourceHttp;
+ }
+
+ public function getSourceEndpoint()
+ {
+ return $this->sourceEndpoint;
+ }
+
public function getTrackers(array $trackers = array())
{
return $this->analytics->getTrackers($trackers);
@@ -5,6 +5,9 @@
<parameters>
<parameter key="google.analytics.trackers" type="collection" />
<parameter key="google.analytics.whitelist" type="collection" />
+ <parameter key="google.analytics.js_source_https">https://ssl</parameter>
+ <parameter key="google.analytics.js_source_http">http://www</parameter>
+ <parameter key="google.analytics.js_source_endpoint">.google-analytics.com/ga.js</parameter>
</parameters>
<services>
@@ -17,6 +20,9 @@
<service id="templating.helper.google_analytics" class="AntiMattr\GoogleBundle\Helper\AnalyticsHelper">
<tag name="templating.helper" alias="google_analytics" />
<argument type="service" id="google.analytics" />
+ <argument>%google.analytics.js_source_https%</argument>
+ <argument>%google.analytics.js_source_http%</argument>
+ <argument>%google.analytics.js_source_endpoint%</argument>
</service>
<service id="twig.extension.google_analytics" class="AntiMattr\GoogleBundle\Extension\AnalyticsExtension" public="false">
@@ -113,7 +113,7 @@ if ( _gaq == null || typeof(_gaq) != 'array') { var _gaq = window._gaq = []; }
(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';
+ ga.src = ('https:' == document.location.protocol ? '{{ google_analytics.sourceHttps | raw }}' : '{{ google_analytics.sourceHttp | raw }}') + '{{ google_analytics.sourceEndpoint | raw }}';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

0 comments on commit 10a204c

Please sign in to comment.