Google Tag Manager

Google Tag Manager

by Gerardo Fallani -
Number of replies: 12

Hello,

I am (not a tech and I'm) trying to have Hotjar analysing the traffic on my Moodle instance (3.5.8, @ https://ital2.org/m/course/view.php?id=5 - free access for guests, without login).

I installed the "Admin tools: Web Analytics" plugin and before this I created an account a tag and everything on Google Tag Manager.

Here I found 2 snippets (see attached file) but I have no idea about where to put them.

Any help?

Attachment Schermata 2019-09-25 alle 13.26.54.png
Average of ratings: -
In reply to Gerardo Fallani

Re: Google Tag Manager

by Gerardo Fallani -
Sorry, maybe I was not very accurate.
Through my cPanel I went into the file manager. There I took a look in several index.php files, including the ones into the Boost theme folder.
Maybe the solution was right under my nose, but I was afraid of getting into any trouble.
So I preferred to ask before...
In reply to Gerardo Fallani

Re: Google Tag Manager

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators

Hi Gerardo.

As this is a question specific to a plugin, it might be best to contact the maintainers directly - e.g. by mentioning this question in a comment down at https://moodle.org/plugins/tool_webanalytics - ideally just provide a link to this discussion thread.

In reply to David Mudrák

Re: Google Tag Manager

by Gerardo Fallani -
Thank you, David.
I'm sorry if I brought some mess into this channel. Sorry.
I'll follow your directions.
Thanks again.
In reply to Gerardo Fallani

Re: Google Tag Manager

by Dmitrii Metelkin -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Gerardo,

Looks like you have done all heavy lifting (got GTM container ID and installed the plugin). To finish up the configuration and start tracking your users, you just need:

  1. Go to /admin/tool/webanalytics/manage.php of your site
  2. Select Google Tag Manager from dropdown list of available tools 
  3. Enter the name for your tool. e.g. "My GTM"
  4. Decide if you'd like to track Admins 
  5. Put GMT-5BK22NN (based on screenshots, looks like this is your container ID ) into Container ID field. 
  6. Save changes.
  7. Profit.

Cheers,

Dmitrii

In reply to Dmitrii Metelkin

Re: Google Tag Manager

by Gerardo Fallani -

Wow! Thanks, it was super easy. Just one minute and it was done!

But please, just to make sure, that snippet was about the header - just a part of the whole I received. 


Don't I need the second part, the one which goes after the body opening tag? Can I ignore it?


In reply to Gerardo Fallani

Re: Google Tag Manager

by Gerardo Fallani -
No way, Dmitrii, I'm sorry.
It appears that to get the tracking I have to insert also the second snippet, the one that goes immediately after the opening body tag.
Now, the page you indicated me, has only one option (header):









I tried following (just a shot, just in case...), the other tools in the main menu (the 2 "Google Analytics" - deprecated and universal).








They do have this option:










But (of course) both them didn't work.

So, I still need a way to find out how (or where) to insert the second snippet.
Any help?
Thanks
In reply to Gerardo Fallani

Re: Google Tag Manager

by Jon Bolton -
Picture of Particularly helpful Moodlers Picture of Testers
Go to Site Admin > Appearance > Additional HTML and enter the second snippet into the second box on that page (“When BODY is opened”)
In reply to Jon Bolton

Re: Google Tag Manager

by Dmitrii Metelkin -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
This is a way to inject the snippet without using Webanalytics tool. Don't use this method if you use the plugin to inject analytics code, otherwise you could get wrong statistics.
In reply to Gerardo Fallani

Re: Google Tag Manager

by Dmitrii Metelkin -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Gerardo!

The plugin should manage it automatically. See it has this snippet https://github.com/catalyst/moodle-tool_webanalytics/blob/master/tool/gtagmanager/templates/noscript_code.mustache and get it rendered on the page https://github.com/catalyst/moodle-tool_webanalytics/blob/master/tool/gtagmanager/classes/tool/tool.php#L45

Make sure that you enable "tracking admins" options while you are testing as most likely you are setting up the plugin being logged in as admin.
In reply to Dmitrii Metelkin

Re: Google Tag Manager

by Gerardo Fallani -
I tried enabling the tracking admins option but the Hotjar badge 





didn't show up.

I also gave a shot the way Jon suggested, but nothing happened this way neither.
In this case I noticed that in the opening body tag it seems that the snipped is already contained (is this what Dmitrii meant?). 











Anyway, I pasted the GTM snippet before "web analytics 1 start" and then I tried with just that (removing from "web analytics 1 start" to the end). So all the combination have been tested. But nothing worked. The verification badge never appeared.





In reply to Gerardo Fallani

Re: Google Tag Manager

by Dmitrii Metelkin -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
Hi Gerardo,
I'm not sure what you are expecting and where you are expecting Hotjar badge to appear. But as per screenshots it seems like the plugin works as expected and it renders required snippet for you.

Do you actually see any statistics at all?  

Cheers,
DmItrii
In reply to Dmitrii Metelkin

Re: Google Tag Manager

by Gerardo Fallani -
I see what you mean, or at least I think I guess...
I can't see the badge but this might be pointless. Anyway, even though in the panel it appears the system is working









I have no "records".
As you can see here











and here