mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
Make sure Google Analytics calls like _anonymizeIp settings happen before calling _trackPageview
This commit is contained in:
parent
ac66302ddc
commit
46aed5481f
2 changed files with 3 additions and 1 deletions
|
|
@ -32,7 +32,6 @@ SETUP_CODE = """
|
|||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', '%(property_id)s']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
%(commands)s
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
|
|
@ -44,6 +43,7 @@ SETUP_CODE = """
|
|||
"""
|
||||
DOMAIN_CODE = "_gaq.push(['_setDomainName', '%s']);"
|
||||
NO_ALLOW_HASH_CODE = "_gaq.push(['_setAllowHash', false]);"
|
||||
TRACK_PAGE_VIEW = "_gaq.push(['_trackPageview']);"
|
||||
ALLOW_LINKER_CODE = "_gaq.push(['_setAllowLinker', true]);"
|
||||
CUSTOM_VAR_CODE = "_gaq.push(['_setCustomVar', %(index)s, '%(name)s', " \
|
||||
"'%(value)s', %(scope)s]);"
|
||||
|
|
@ -87,6 +87,7 @@ class GoogleAnalyticsNode(Node):
|
|||
commands = self._get_domain_commands(context)
|
||||
commands.extend(self._get_custom_var_commands(context))
|
||||
commands.extend(self._get_other_commands(context))
|
||||
commands.append(TRACK_PAGE_VIEW)
|
||||
if getattr(settings, 'GOOGLE_ANALYTICS_DISPLAY_ADVERTISING', False):
|
||||
source = DISPLAY_ADVERTISING_SOURCE
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class GoogleAnalyticsTagTestCase(TagTestCase):
|
|||
def test_anonymize_ip(self):
|
||||
r = GoogleAnalyticsNode().render(Context())
|
||||
self.assertTrue("_gaq.push (['_gat._anonymizeIp']);" in r, r)
|
||||
self.assertTrue(r.index('_gat._anonymizeIp') < r.index('_trackPageview'), r)
|
||||
|
||||
@override_settings(GOOGLE_ANALYTICS_ANONYMIZE_IP=False)
|
||||
def test_anonymize_ip_not_present(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue