Google Analytics code can be added to the Astra theme with the Astra Hooks plugin. It provides hooks so that you can insert custom code at various locations on the website without editing the theme’s core files.
Please follow the steps to add the Google Analytics code-
- Download the Astra Hooks plugin. Install it like any other WordPress plugin and activate it.
- From the WordPress dashboard navigate to Appearance > Customizer > Hooks > Header > wp_head.
- Add the code with the wp_head action.
- Publish it.
Please note that you will need to place the code in between the <scripts> and </scripts> sections.
Other Notes:
Astra Pro Addon plugin users can add Google Analytics code with Custom Layouts Module. (Recommended)