2buntu / 2buntu-blog

Source code for the 2buntu blog.
http://2buntu.com
Apache License 2.0
15 stars 11 forks source link

Add option for Google Analytics code #37

Closed nathan-osman closed 10 years ago

nathan-osman commented 10 years ago

There is currently no way to specify the Google Analytics code, which is needed for integrating with... Google Analytics. This should not be hardcoded into the templates.

nitstorm commented 10 years ago

I use something like this for my Jekyll blog -> https://github.com/nitstorm/motoko/blob/master/_layouts/default.html storing the value of the tracking code identifier alone from the user in a variable.

Take a look at the end of the page, would that work?

But, we are talking about not hardcoding it into templates, so how about something like if google analytics variable is set, then include google-analytics-snippet.html or something like that?

nathan-osman commented 10 years ago

Well, with Django it's easiest to add this setting to local_settings.py and the just use {% if %} ... {% endif %} in base.html.

nitstorm commented 10 years ago

:+1:

nathan-osman commented 10 years ago

I changed my mind. :smile: I am going to hardcode the Google Analytics tracking script for two reasons:

  1. It's easier than going through the trouble of writing middleware to expose the setting.
  2. People can view the page source so it's not a secret. No reason to "hide" it.