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