How to enable Google Analytics

I cant see anywhere I can enable setup for Google Analytics. Nor can I find a plugin. So how does one do this in Discourse?

2 Likes

The topic at Setup Google Tag Manager for Analytics describes how to setup Google Tag Manager on Discourse. We seem to be missing a #howto topic that deals with just setting up Google Analytics.

If you are not using Google Tag Manager, all you need to do to setup Google Analytics is add your Google Analytics tracking code to the Discourse ga universal tracking code site setting, and your domain name to the ga universal domain name site setting. When the ga universal tracking code site setting is set, Discourse will automatically load the analytics script.

8 Likes

@simon
If you notice in the Solved by it shows “in post #3”. There were only two posts in before I posted this. It incorrectly showed “post #3” instead of post 2. Here’s what it’s showing. Feel free to create a topic for this if needed. :slightly_smiling_face:

image

2 Likes

There was originally another response which was deleted. It looks like we’re not catching that edge case.

4 Likes

I’m not using Tag Manager, so this is the answer I was looking for. After entering the data from GA in this fields, nothing happens. What do you have to do next to enable it? I see nothing in the rendered pages source related to GA anywhere.

1 Like

I have just tested this out on my own site. After adding my analytics Tracking ID to the Discourse ga universal tracking code site setting, I am seeing activity from the site on my Analytics page.

If you open your browser’s web inspector to its Console tab on your forum, you may see Content Security Policy violations listed there. If you are seeing errors, can you check to see if https://www.google-analytics.com has been added to your Discourse site’s content security policy script src setting? That source should be automatically added by Discourse when the universal tracking code is set, but possibly it hasn’t been added on your site.

If you are not seeing any Content Security Policy errors, then the problem may be with your the configuration on your Google Analytics account.

7 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.