Context Processors


Most projects have the Google Analytics tracking code in their base template. If you like to put that code into a partial template or even re-use your whole base template between projects, then it would be a good idea to set the analytics code in your and add it to your template context using this context processor.

Add the processor to your list of context processors:


Use it in your template:

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', '{{ ANALYTICS_TRACKING_ID }}', '{{ ANALYTICS_DOMAIN }}');
  ga('send', 'pageview');