HelpNDoc's default HTML template supports Google Tag Manager, which is used to install, store and manage marketing tags without modifying the documentation's code. It follows Google Tag Manager's best practice by adding the correct code both in the head and in the body sections of the generated HTML documentation.

Retrieve Google Tag Manager's ID

HelpNDoc will only add Google Tag Manager's code if the ID is specified for a build. Here is how to get the ID:

Assign the ID to a HTML build

Now that we have the ID, here is how you can set it in your HelpNDoc HTML build:

  • From HelpNDoc's "Home" ribbon tab, in the "Project" group, click the top part of the "Generate help" button
  • Select the HTML build on the list
  • Make sure that it uses the "Default HTML template"
  • If the "Template settings" tab is not visible, click "Customize"
  • In the "Template settings" tab, locate the "Google Tag Manager Id" row and paste the previously retrieved ID

That build is now ready to use Google Tag Manager: next time it is generated, it will automatically produce the correct code to use Google Tag Manager.

Handle the "History Change" event

As HelpNDoc's default HTML template uses various optimization techniques to speed-up the display of HTML documentation pages, it won't reload the whole page when the user clicks another topic in the table of contents, which will lead to lost Google Tag Manager PageView events. To work around that, in your Google Tag Manager's administrator console: