Add google tag to Neos CMS

I want to track the products that users are adding in the cart and the product views for that I want to google tag and dataLayer, but I dont know how to do it in neos, can someone help me

the only neos specific thing is the rendering process, eg that fusion is used for rendering pages.

so you could extend your Abstract page or the base page to include your javascript on any! page. prototype(Neos.Neos:Page).head.javascripts.myGoogleStuff = "<script ... />"

to add scripts only on certain sites is depending on your whole rendering process - eg you might add the above only to

prototype(My.Site:Document.Product) < prototype(Neos.Neos:Page) {
    head.javascripts.myGoogleStuff = "<script ... />"

I tried doing this, but it is not being added in dataLayer
head = Neos.Fusion:Array {
head.javascripts.myGoogleStuff = ""

You are adding the “head” tag twice - copy paste
this and head is already defined in the default Page object.

If it’s about plain Google Analtics, this package could serve you as example or use it

If not: Can you show your Fusion file for context?

For reference, the Neos SEO package add to the head part like this

If you look at the GoogleSiteVerification line, it referres to a separate Prototype - and you can do the same. For reference, the GoogleSiteVerification is like this

1 Like