How to Add a Google Verification Tag to the <head> Section of a Website Using the HubSpot API?

Hi HubSpot Community,

I’m developing a HubSpot app and need to add a Google site verification meta tag dynamically to the <head> section of all pages for user website who install my app.

I want this process to be automated so users don’t have to manually edit their templates.

I’d like to know:

  • What’s the best approach to achieve this in a scalable way?
  • Is there a API way to modify the <head> section for all pages upon app installation?
  • Are there any limitations or best practices I should consider for app compliance with HubSpot?

Any guidance or examples would be greatly appreciated! Thanks in advance.

Hi @U072319,

As far as I know, there currently aren’t any options that would allow you to modify the HTML header/footer settings either site-wide or on individual pages.

The closest thing you get to is having a custom module be added to a page that would have the tag present, wrapped in a {% require_head %} statement, which would make it load in the <head> of the page. However, that would require a complex setup of retrieving each page individually via the Pages API, updating the retrieved code and then doing a PATCH call to those pages to update them.

Not sure why you would need to add the Google site verification tag to all pages - the homepage should be enough - though even if it is just one page, automating placing a module might be a challenge as not all templates are built equal.

Not saying technically could not be done, but seems like ti could be too much risk and complexity for the use case.