1

I currently have a django cms website and will like to have google analytics installed, using the aldryn-google-analytics plugin.

I don't have a Divio Cloud account, and I'm really new to python.

May I seek your advice on the GitHub files to be added to my project please and where the files should be placed into project.

hzh
  • 41
  • 1
  • 6

2 Answers2

1
  • If you're using Divio Cloud for your django CMS project, the Google Analytics addon can be a good way to add Google Analytics to a site (useful if you are for example a web manager who doesn't have access to site code).

  • If you're not, just copy and paste the JS snippet provided by Google into your template.

In fact you can do that even if you're on Divio Cloud.

Daniele Procida
  • 1,477
  • 10
  • 27
0

Doesn't look like you need a Divio Cloud account. Looks like it just needs some settings defined. Take a look at this part of that app;

google_analytics_id = getattr(settings, 'GOOGLE_ANALYTICS_ID', None)
use_universal_analytics = getattr(settings, 'GOOGLE_ANALYTICS_USE_UNIVERSAL', False)
track_individuals = getattr(settings, 'GOOGLE_ANALYTICS_TRACK_INDIVIDUALS', False)

From that, you can see it'll work if you provide your analytics ID as the following setting in your django settings file; GOOGLE_ANALYTICS_ID

You can also optionally enable the following two settings (True or False) to enable those features; GOOGLE_ANALYTICS_USE_UNIVERSAL, GOOGLE_ANALYTICS_TRACK_INDIVIDUALS

Alternatively you could just drop the javascript from analytics in to your templates. Usually it's easy to just include it in a base.html that gets inherited in to all pages.

markwalker_
  • 12,078
  • 7
  • 62
  • 99
  • thanks for your help. From this [article](http://divio-cloud-developer-handbook.readthedocs.io/en/latest/background/anatomy-addon.html), I think we are unable to directly edit settings.py. Any advice how Github [files](https://github.com/aldryn/aldryn-google-analytics) should be incorporated into project? – hzh Oct 21 '17 at 01:28
  • @vsg I thought you said you don't have a divio cloud account, so surely you're just hosting your own python website? Just download the app from github (green button) and add it to your project. – markwalker_ Oct 21 '17 at 12:31
  • I thought the article on divio app anatomy will be relevant because the aldryn-google-analytics is from divio. do i add every file on github into my project? at which folder level do I add the files? thank you. – hzh Oct 22 '17 at 14:36
  • @vsg to use it as it is, you'd need to implement this aldryn package which is uses; https://github.com/aldryn/aldryn-snake Otherwise you could convert the `get_google_analytics_script()` into a middleware tool or context processor to add your analytics to requests. Alternatively get a django package built for analytics; https://djangopackages.org/packages/p/django-analytical/ – markwalker_ Oct 22 '17 at 15:05