django-ganalyticsSimple Google Analytics integration for Django | |
Download |
django-ganalytics Ranking & Summary
Advertisement
- License:
- Public Domain
- Price:
- FREE
- Publisher Name:
- Randall Degges
- Publisher web site:
- http://github.com/comradeb14ck/
django-ganalytics Tags
django-ganalytics Description
django-ganalytics is a Django app that integrates Google Analytics with Django.Developer commentsHonestly, all the other Google Analytics Django apps suck. All I want to do is put my Google Analytics code in my ``settings.py`` file, and use a simple template tag to render the Google Analytics asynchronous javascript code, damnet!Unfortunately, all the existing solutions don't do this, and that pisses me off!Installation and UsageAnyway, let's install this bitch! The first thing you'll want to do is run:pip install django-ganalyticsNext, modify your ``settings.py`` file, and add your Google Analytics code (usually something like ``UA-XXXXXXXX-XX``), as well as put ``ganalytics`` in your ``INSTALLED_APPS``:python# settings.pyINSTALLED_APPS = ( # ... 'ganalytics',)GANALYTICS_TRACKING_CODE = 'UA-XXXXXXXX-XX'Now, to actually render your Google Analytics asynchronous javascript code, edit your desired Django template (I like to do this in my ``base.html`` template), and add the following: html{% load ganalytics %}< !--- ... -- >< head > {% ganalytics %}< /head >< !--- ... -- >When Django processes your template, it'll replace ``{% ganalytics %}`` with:html< script type="text/javascript" > var _gaq = _gaq || []; _gaq.push(); _gaq.push(); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script'); s.parentNode.insertBefore(ga, s); })();< /script >Easy, right?Product's homepage
django-ganalytics Related Software