Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2 from gimler/master.

trackPageLoadTime and on,off to true,false
  • Loading branch information...
commit 7904d1328ba9391a8ec614e34de58951a11ae96f 2 parents 23c24dd + 24a5949
Kris Wallsmith authored
6 README
View
@@ -42,7 +42,7 @@ Basic configuration is done in your application's `app.yml` file:
#!yaml
all:
sf_google_analytics_plugin:
- enabled: on
+ enabled: true
profile_id: XX-XXXXX-X
tracker: google
}}}
@@ -152,13 +152,13 @@ all:
# disable tracking for this module...
sf_google_analytics_plugin:
params:
- enabled off
+ enabled: false
# ...or for a single action
index:
sf_google_analytics_plugin:
params:
- enabled off
+ enabled: false
}}}
Alternatively, you can access the tracker object directly from inside your action:
17 config/app.yml
View
@@ -1,6 +1,6 @@
# all:
# sf_google_analytics_plugin:
-# enabled: off
+# enabled: false
# profile_id: XX-XXXXX-X
# insertion: bottom
# tracker: urchin
@@ -13,22 +13,23 @@
# params:
# page_name: ~ # this setting should be used in module.yml, not app.yml
# domain_name: ~
-# linker_policy: off
+# linker_policy: false
# organic_referers: [{ name: ~, param: ~ }]
# vars: [] # this setting also makes more sense to use in module.yml, not app.yml
# cookie_path: /
-# client_info_policy: on
-# hash_policy: on
-# detect_flash_policy: on
-# detect_title_policy: on
+# client_info_policy: true
+# hash_policy: true
+# detect_flash_policy: true
+# detect_title_policy: true
# session_timeout: 3600 # 30 minutes
# cookie_timeout: 31536000 # six months
# campaign_keys: { name: ~, source: ~, medium: ~, term: ~, content: ~, id: ~, no_override: ~ }
-# anchor_policy: off
+# anchor_policy: false
+# track_page_load_time: false
# ignored_organics: []
# ignored_referers: []
# sample_rate: 100 # 100%
-# local_remote_server_policy: off
+# local_remote_server_policy: false
#
# # specific to "google" tracker
# tracker_var: pageTracker
26 lib/tracker/sfGoogleAnalyticsTracker.class.php
View
@@ -138,12 +138,17 @@ public function configure($params)
{
$this->setLocalRemoteServerPolicy($params['local_remote_server_policy']);
}
-
+
if (!is_null($params['anchor_policy']))
{
$this->setAnchorPolicy($params['anchor_policy']);
}
-
+
+ if (!is_null($params['track_page_load_time']))
+ {
+ $this->setTrackPageLoadTime($params['track_page_load_time']);
+ }
+
if (!is_null($params['client_info_policy']))
{
$this->setClientInfoPolicy($params['client_info_policy']);
@@ -661,7 +666,22 @@ public function getCampaignNoOverrideKey()
{
return $this->campaignNoOverrideKey;
}
+
+ /**
+ * Track page load time or not.
+ *
+ * @param bool $enabled
+ */
+ public function setTrackPageLoadTime($enabled)
+ {
+ $this->trackPageLoadTime = (bool) $enabled;
+ }
+ public function getTrackPageLoadTime()
+ {
+ return $this->trackPageLoadTime;
+ }
+
/**
* Define an anchor policy.
*
@@ -830,7 +850,7 @@ protected function doInsert(sfResponse $response, $content, $position = null)
switch ($position)
{
case self::POSITION_TOP:
- $new = preg_replace('/<body[^>]*>/i', "$0\n".$content."\n", $old, 1);
+ $new = str_ireplace('</head>', "\n".$content."\n</head>", $old);
break;
case self::POSITION_BOTTOM:
5 lib/tracker/sfGoogleAnalyticsTrackerAsynchronous.class.php
View
@@ -230,6 +230,11 @@ public function insert(sfResponse $response)
$html[] = sprintf('%s.push(["_trackPageview"]);', $tracker);
}
+ if ($this->getTrackPageLoadTime())
+ {
+ $html[] = sprintf('%s.push(["_trackPageLoadTime"]);', $tracker);
+ }
+
foreach ($this->getVars() as $var)
{
$html[] = sprintf(
11 lib/tracker/sfGoogleAnalyticsTrackerGoogle.class.php
View
@@ -134,12 +134,12 @@ public function insert(sfResponse $response)
{
$html[] = sprintf('%s._setCampNOKey(%s);', $tracker, $noOverrideKey);
}
-
+
if ($this->getAnchorPolicy())
{
$html[] = sprintf('%s._setAllowAnchor(true);', $tracker);
}
-
+
foreach ($this->getIgnoredOrganics() as $keyword)
{
$html[] = sprintf('%s._addIgnoredOrganic(%s);', $tracker, $keyword);
@@ -172,7 +172,12 @@ public function insert(sfResponse $response)
{
$html[] = sprintf('%s._trackPageview();', $tracker);
}
-
+
+ if ($this->getTrackPageLoadTime())
+ {
+ $html[] = sprintf('%s._trackPageLoadTime();', $tracker);
+ }
+
foreach ($this->getVars() as $var)
{
$html[] = sprintf('%s._setVar(%s);', $tracker, $this->escape($var));
Please sign in to comment.
Something went wrong with that request. Please try again.