Login

Google Analytics Template Tag

Author:
blinks
Posted:
November 5, 2007
Language:
Python
Version:
.96
Score:
2 (after 4 ratings)

Use {% urchin "UA-1234567-1" %} to insert the Javascript snippet for a Google Analytics site.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from django import template

register = template.Library()

def urchin(uacct):
    return """
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "%(uacct)s";
urchinTracker();
</script>
""" % { 'uacct': uacct }

register.simple_tag(urchin)

More like this

  1. Browser-native date input field by kytta 4 weeks, 1 day ago
  2. Generate and render HTML Table by LLyaudet 1 month, 1 week ago
  3. My firs Snippets by GutemaG 1 month, 1 week ago
  4. FileField having auto upload_to path by junaidmgithub 2 months, 2 weeks ago
  5. LazyPrimaryKeyRelatedField by LLyaudet 2 months, 3 weeks ago

Comments

jerzyk (on December 17, 2007):

good thing will be to tie this to settings.py and/or sites framework.

#

jarofgreen (on July 28, 2009):

it's worth noting the google javascript has changed since this was posted

#

Please login first before commenting.