Site Builder module available with Astra Pro Addon plugin allows addingย Google Tag Manager code to the website.ย It provides hooks so that you can insert custom code at various locations on the website without editing themeโs core files.
This is a premium feature available with Astra Pro Addon plugin. To use these Pro features, you need to have the Astra theme along with the Astra Pro Addon installed on your website.
Go through the following sections of this document to know more about how to add Google Tag Manager code using Site Builder module in Astra Pro.
How to Add Google Tag Manager Code to Astra?
Google Tag Manager code has two code snippets. One to be added as close to the opening <head> tag as possible and other immediately after the opening <body> tag. To add both code snippets, add two different Custom Layouts. Below are the steps to create Custom Layout and add code using hooks.
1. Custom Layout to add code toย <head> tag
- Activate the Site Builder module from Astra Pro.
- Add a new Custom Layout from Astra > Site Builder
- Selectย Hooksย layout
- ย Insert the code in the Code Editor and set wp_headย as action.
- Choose to display it on Entire Website.
- Publish the layout.
2. Custom Layout to add code toย <body> tag –
- Add a new Hooks Custom Layout.
- Insert the code in the Code Editor.
- Select Hooks layout and add body_top action.
- Choose to display it on Entire Website.
- Publish the layout.
Thus by successfully integrating Google Tag Manager into your Astra website, you’ve opened a gateway to enhanced tracking, analysis, and optimization.
We hope this document has been helpful. If you have any queries further, feel free to leave a comment below.