Skip to content

Conversation

@dessibelle
Copy link

I modified this app in order to suit my needs, and thought I might as well share my modifications. They can be considered add-ons only, as the app stil retains all of its current functionality. I didn't want to put my GA account code in my template, so I thought I'd just supply the analytics template tag with a variable holding my key. That didn't work since the tag required input to be quoted in double quotes. I therefore ended up making the following to modifications to the app:

  1. Quoting of the template tag input argument is no longer required. Instead leading/trailing quotes (single and double) are regexed away if present.
  2. If the settings key GOOGLE_ANALYTICS_KEY is present in your project its value will be used as code by the template tag if no code is supplied. At the moment this setting also takes precedence over the Sites-framework based solution (as that is what suited my needs).

This has the following implications (improvements if you ask me):

  • {% analytics %} will return the code specified in settings.GOOGLE_ANALYTICS_KEY if present, and otherwise use the Sites framework.
  • {% analytics my_code %} is now also an options (my_code being a template variable holding the code).
  • {% analytics "UA-123456-7" %} still works fine, as does {% analytics 'UA-123456-7' %} and {% analytics UA-123456-7 %}.

@dessibelle
Copy link
Author

Haha, could've checked the existing PR's beforehand 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant