Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Commit

Permalink
support Google Analytics subdomains and multiple top-level domains tr…
Browse files Browse the repository at this point in the history
…acking
  • Loading branch information
smellman committed May 16, 2013
1 parent a032827 commit 135813e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/source/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ things you may need or wish to modify:
``GOOGLE_ANALYTICS_ID``
Your ID from `Google Analytics <http://www.google.com/analytics/>`_

``GOOGLE_ANALYTICS_SUBDOMAINS``
If you use subdomains with `Google Analytics <http://www.google.com/analytics/>`_ , set your subdomains.

``GOOGLE_ANALYTICS_MULTIPLE_TOPLEVEL_DOMAINS``
If you use multiple top-level domains with `Google Analytics <http://www.google.com/analytics/>`_ , set ``True``.

``SITE_THEME``
The name of the directory under ``themes`` to look for the theme templates
and static files. We'll have more detail on creating a theme soon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ CLOUDMADE_API_KEY = 'CLOUDMADEAPIKEYHERE'

# Get a Google Analytics ID at https://www.google.com/analytics.
GOOGLE_ANALYTICS_ID = ''
# If use 'Subdomains' with Google Analytics, set here
GOOGLE_ANALYTICS_SUBDOMAINS = ''
# If use 'Multiple top-level domains' with Google Analytics, comment out here
# GOOGLE_ANALYTICS_MULTIPLE_TOPLEVEL_DOMAINS = True

# For testing, you can start the python debugging smtp server like so:
# sudo python -m smtpd -n -c DebuggingServer localhost:25
Expand Down
6 changes: 6 additions & 0 deletions sapling/themes/sapling/templates/site/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ GOOGLE_ANALYTICS_ID }}']);
{% if GOOGLE_ANALYTICS_SUBDOMAINS %}
_gaq.push(['_setDomainName', '{{ GOOGLE_ANALYTICS_SUBDOMAINS }}']);
{% if GOOGLE_ANALYTICS_MULTIPLE_TOPLEVEL_DOMAINS %}
_gaq.push(['_setAllowLinker', true]);
{% endif %}
{% endif %}
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
Expand Down
4 changes: 3 additions & 1 deletion sapling/utils/context_processors/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ def license_agreements(context):

def services(context):
return {
'GOOGLE_ANALYTICS_ID': getattr(settings, 'GOOGLE_ANALYTICS_ID', '')
'GOOGLE_ANALYTICS_ID': getattr(settings, 'GOOGLE_ANALYTICS_ID', ''),
'GOOGLE_ANALYTICS_SUBDOMAINS': getattr(settings, 'GOOGLE_ANALYTICS_SUBDOMAINS', ''),
'GOOGLE_ANALYTICS_MULTIPLE_TOPLEVEL_DOMAINS': getattr(settings, 'GOOGLE_ANALYTICS_MULTIPLE_TOPLEVEL_DOMAINS', False)
}

0 comments on commit 135813e

Please sign in to comment.