0
votes

The company I work for has an existing website with hundreds of pages. We have not implemented Google Analytics or Google Tag Manager on our site at this point. Based upon what I have read, it seems like using the container code for the Google Tag Manager would be the best route for us.

Is anyone aware of any automated solutions to getting the GA or GTM code on all of the webpages of a website, or is the only option to do this manually?

If it can only be done manually, does anyone know if large websites typically track every single page on the website or do they select key pages to implement the code?

2

2 Answers

2
votes

If your web pages are in a database and you want to automate this, then use a script to access each page in the database and add the Google code.

if your website uses templates and the pages use a certain template, just edit themplate header (or whatever) and add the Google code there

If your webpages are just plain html/text files , create a script to read each page file and add the Google code where needed (use some regular expressions in Node for example)

In any case using a (custom) automated script will come in handy since other batch changes are likely to happen as well

0
votes

What kind of website is it? Is it built with a CMS or template system? Or is it built with a large number of separate HTML files?

In a template or CMS, you could add the Google Tag Manager container code in the header or footer template (just where you want it).

In a HTML site, you could use a search and replace action on the whole folder, for example on the </head> or </body>, where you add in the Google Tag Manager code in the replacement.