mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-05-05 06:04:44 +00:00
improve variable names and snippet readability
This commit is contained in:
parent
440d078d86
commit
2a13008ffc
1 changed files with 7 additions and 6 deletions
|
|
@ -38,7 +38,7 @@ SETUP_CODE = """
|
|||
%(commands)s
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? %(display_advertising)s;
|
||||
ga.src = ('https:' == document.location.protocol ? %(source_scheme)s) + %(source_url)s;
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
|
|
@ -51,8 +51,8 @@ CUSTOM_VAR_CODE = "_gaq.push(['_setCustomVar', %(index)s, '%(name)s', " \
|
|||
"'%(value)s', %(scope)s]);"
|
||||
SITE_SPEED_CODE = "_gaq.push(['_trackPageLoadTime']);"
|
||||
ANONYMIZE_IP_CODE = "_gaq.push (['_gat._anonymizeIp']);"
|
||||
WITHOUT_DISPLAY_ADVERTISING = "'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'"
|
||||
WITH_DISPLAY_ADVERTISING = "'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'"
|
||||
DEFAULT_SOURCE = ("'https://ssl' : 'http://www'", "'.google-analytics.com/ga.js'")
|
||||
DISPLAY_ADVERTISING_SOURCE = ("'https://' : 'http://'", "'stats.g.doubleclick.net/dc.js'")
|
||||
|
||||
register = Library()
|
||||
|
||||
|
|
@ -81,12 +81,13 @@ class GoogleAnalyticsNode(Node):
|
|||
commands.extend(self._get_custom_var_commands(context))
|
||||
commands.extend(self._get_other_commands(context))
|
||||
if getattr(settings, 'GOOGLE_ANALYTICS_DISPLAY_ADVERTISING', False):
|
||||
display_advertising = WITH_DISPLAY_ADVERTISING
|
||||
source = DISPLAY_ADVERTISING_SOURCE
|
||||
else:
|
||||
display_advertising = WITHOUT_DISPLAY_ADVERTISING
|
||||
source = DEFAULT_SOURCE
|
||||
html = SETUP_CODE % {'property_id': self.property_id,
|
||||
'commands': " ".join(commands),
|
||||
'display_advertising': display_advertising}
|
||||
'source_scheme': source[0],
|
||||
'source_url': source[1]}
|
||||
if is_internal_ip(context, 'GOOGLE_ANALYTICS'):
|
||||
html = disable_html(html, 'Google Analytics')
|
||||
return html
|
||||
|
|
|
|||
Loading…
Reference in a new issue