The following steps explain how to add Global Site Tag (gtag.js) -Google Analytics code to Weebly site.
Go to Google Tag Manager account (https://tagmanager.google.com/) and create an account for your Weebly site.
Once you accept GTM terms and conditions, GTM snippet code box will pop up. Copy the code for <head> section and head over to your Weebly site.
Log in to your Weebly account, select the site to which you want to add Google Analytics Code.
Go to Settings --> SEO.
In the header code section, paste the GTM snippet code in the top.
Save and publish.
Log in to your Google Analytics site, copy Tracking ID: e.g: UA-XXXXXX-X under Property.
Go to Tag Manager site and select tags on the left navigation panel.
Create new tag ( Follow below steps to configure UA- Tracking ID within GTM)
(i) click Tag Configuration & choose Tag Type as Google Analytics -Universal Analytics
(ii) Track Type: Pageview
(iii) Google Analytics settings Variable --> select New variable and paste the Tracking ID copied from Google Analytics site.
(iv) Triggering: Choose all page views
(v) Click Preview to see your added tags and then submit.
Verifying Google Analytics Tracking
How to check if Google Analytics is working for you.
(1) Add Chrome extension Tag Assistant (By Google). If Google Analytics code is installed properly, you will instantly see tracking ID.
(2)In Google Analytics, go to ADMIN --> Property -->Tracking Code --> click on send test traffic.
Then, under Reports (on left navigation panel) choose Real - Time --> Overview.
Since you sent a test traffic to your site, you should at least see 1 active user on your site to verify that your analytics code is working properly.