Google Tag Manager Install for Kentico 9

merav tg asked on April 20, 2016 11:07

Hello,

I would like add the Google Tag Manager script to my site (Kentico 9).

It's seems like the snippet can be recognized only if placed right after the body tag. Adding it via a web part (I've tried both the HTML & Javascript webpart) encloses it in a div and render an error (see screenshot). I've also tried to install it via the Google Tag Manager Installer from the Marketplace but unfortunately it is not compatible with Kentico 9. (see 2nd screenshot)

Can you help me?

All the best,

Image Text

Image Text

Recent Answers


Jan Hermann answered on April 20, 2016 11:24

If you need to have the code right after the body tag, you can customize the /CMSPages/PortalTemplate.aspx template or better you can create custom portal template and put the code there. This template is used for generating all the portal live site pages.

0 votesVote for this answer Mark as a Correct answer

merav tg answered on April 20, 2016 12:45

Is it possible to customize the PortalTemplate.aspx using the Kentico CMS Desk?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 20, 2016 14:12

Using the HTML and JavaScript webparts does NOT render any additional div tags so you must have something coded or setup to wrap them with a div tag. I'm guessing your ZoneContent zone has a div wrapper in the layout. NOTE modifying the /CMSPages/PortalTemplate.aspx file will cause breaking changes for future upgrades. Also note, you are not able to modify it from the Kentico Admin UI.

What I would do is modify your master page template's layout and place it in the layout at the very top of the layout. I've installed several GTM codes and have had no problem with this approach or using a JavaScript webpart.

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on April 20, 2016 14:13 (last edited on April 20, 2016 14:40)

Hi Merav,

Per google documentation this code should be available on all pages right after body tag. SO only way you should do this is to add via Master Template.

Can't you go to the Master Template Page and add code right after body tag in the wysiwyg?

I have added a screen shot for your reference. I do this way without any problem.

Let me know if this helps.

Cheers, Chetan

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.