Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# profile_id: XX-XXXXX-X
# insertion: bottom
# tracker: urchin
# insert_custom_vars_if_ajax: false # Only implemented for async tracker:
# # in ajax requests, insert ONLY the custom vars, if they are defined.
# # You still need to make a js call with _trackPageView/_trackEvent (in js, for example)
# # This feature was designed to works with pjax, which triggers a _trackPageView() after request
# classes:
# urchin: sfGoogleAnalyticsTrackerUrchin
# google: sfGoogleAnalyticsTrackerGoogle
Expand All @@ -16,6 +20,8 @@
# linker_policy: false
# organic_referers: [{ name: ~, param: ~ }]
# vars: [] # this setting also makes more sense to use in module.yml, not app.yml
# custom_vars: # this setting also makes more sense to use in module.yml, not app.yml
# - [ 0, "name", "value", 1 ] # Example [ slotNumber, variableName, variableValue, scope ]
# cookie_path: /
# client_info_policy: true
# hash_policy: true
Expand Down
13 changes: 13 additions & 0 deletions lib/filter/sfGoogleAnalyticsFilter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,19 @@ public function execute($filterChain)

$tracker->insert($response);
}
elseif (sfConfig::get($prefix.'insert_custom_vars_if_ajax', false)
&& $tracker->hasCustomVars()
&& $request->isXmlHttpRequest()
&& $tracker->isEnabled())
{

if (sfConfig::get('sf_logging_enabled'))
{
sfGoogleAnalyticsToolkit::logMessage($this, 'Inserting tracking code for custom vars only (ajax call).');
}

$tracker->insertOnlyCustomVars($response);
}
elseif (sfConfig::get('sf_logging_enabled'))
{
sfGoogleAnalyticsToolkit::logMessage($this, 'Tracking code not inserted.');
Expand Down
Loading