To install Google Analytics in WordPress without a plugin, you can paste the tracking code to either the footer.php or header.php file of your theme. You can paste your Google Analytics tracking code to these files because they are loaded every time a user visits a post or page of your website.
If you use Elementor Pro and use its Theme Builder feature to create a custom header and custom footer for your website, Google Analytics will stop working since when you create a custom header and custom footer with Elementor Pro, they (the custom footer and custom header) will replace the default header and footer of your active theme. You need to re-install Google Analytics to have it works again.
How to install Google Analytics in Elementor without a plugin
There are several plugins that you can use to install Google Analytics on your Elementor-based website. If you prefer to install Google Analytics without a plugin, there is also a way to do so.
First, go to Templates -> Theme Builder. On the Theme Builder page, click the Footer tab. Hover your mouse over the footer template you use on your website and click Edit with Elementor.
Add the HTML widget by dragging it to your custom footer on the canvas area. You can place it anywhere within the footer.
Paste your Google Analytics tracking code to the HTML Code field on the left panel and click the UPDATE button.
You have successfully reinstalled your Google Analytics on your Elementor-based website without a plugin. If you find a problem to find the tracking code on your previous installation, you can read this article to learn more.
Installing Google Analaytics on Elementor 3.1.1 and the newer versions
Since version 3.1.1, Elementor (the pro version) comes with a Custom Code feature which you can use to add a custom code. You can make use of this feature to install Google Analytics.
First, go to Elementor -> Custom Code on your WordPress dashboard. Add a new custom code by clicking the Add new button.
Give your custom code a name and paste the Google Analytics tracking to the available field. On the Location option, select the HTML tag you want your code to be added (we suggest you choose the head tag). On the Priority option, you can leave it default. Publish the custom code by clicking the Publish button.
On the next step, you can set the display condition. If you want the tracking code to be loaded on every page of your website, you can simply select Entire Site on the dropdown menu. Or, if you want the tracking code to be loaded on a specific page, you can simply select your preferred page on the dropdown menu as well. End by clicking the Save & Close button.