AIM
Using Django to install Google Analytics.
PROBLEM
It isn't clear to me if I need to apply the following lines to ALL the templates I am interested in tracking or just to index.html.
{% load google_analytics_tags %}
<div style="display:none">
<img src="{% google_analytics %}" width="0" height="0" />
</div>
If the answer is that by simply pasting it into index.html would add it to all my existing templates, how can I exclude the pages I don't want any tracking from?
I am following the steps from: https://pypi.org/project/django-google-analytics-app/
Thanks in advance for your help.
The best way would be to create a seperate template called analytics.html
and put your analytics code in this file then add the line
{% include "analytics.html" %}
to the files you want to track analytics for.
In that template called analytics.html I would paste the code exactly as it is in my question right? Including {% load google_analytics_tags %} ?
@Joehat I see that you are using pypi.org/project/django-google-analytics-app I have not personally used this library but according to their documentation seems like it should work.
I forgot to include the link to the question. I've just edited it. From that same link, in step 3. would I paste
(r'^djga/', include('google_analytics.urls')),
as it is in urls.py or should I paste it inside something else and in step 4. where wouldGOOGLE_ANALYTICS = { 'google_analytics_id': 'xxx', }
go? Is it in settings.py ? Thanks you for help!yes, you are right, the first part goes in
urls.py
and second insettings.py