Archived topic
Setting up Google Tag Manager Data Layer in GeneratePress
3 replies · Started by pairfum on September 6, 2019
Dear Support Forum,
We have implemented Google Tag Manger using this excellent guide and it works very well:
https://docs.generatepress.com/article/implement-google-tag-manager/
We would now like to add 'Data Layers' in Google Tag Manager and we are following this guide:
https://juliencoquet.com/en/2014/01/22/data-layer-google-tag-manager-for-wordpress/
Our question is: How do we implement it in GeneratePress?
We presume by creating a new Hook Element with the following settings:
- Content > this is where we paste the code from the guide
- Settings > Hook > ??? -> which hook is best ? According to the link, it should go should go in the WordPress header of the child theme but before Google Tag Manager container snippet
- Settings > Priority > ??? -> should the priority be zero?
- Display Rule > Location > Entire Site
- any other settings, e.g. 'execute php' ?
Many thanks for your help on this.
Kind regards,
Pairfum London
https://www.pairfum.com
Hi there,
Looks like it should go in wp_head as well.
Since it needs to go before GTM, you can set the GTM code to priority 5 and this one to priority 2.
Setting it to the entire site should be good and also execute PHP.
Let me know :)
Hi Leo,
Many thanks for your quick response & advice.
Your tip about setting the priority is very good:
- 2 for the Data Layer hook, and
- 5 for the main GTM container.
I had been wondering how to fire it before the main GTM container in wp_head.
'Entire site' has been set and 'execute php' ticked.
Again, many thanks for your help.
Kind regards,
Pairfum London
No problem :)