Basic instructions
- If you have not already done so, create a Universal Analytics property for each website that you want to collect data from.
Creating a property generates a unique Tracking ID and the Google tag that includes the Tracking ID for that property. See the following section for information about finding your Tracking ID and the Google tag. - Copy and paste the Google tag after the opening
<head>
tag on each page you want to measure.
Find your Tracking ID and Google tag
- Sign in to your Analytics account.
- Click Admin.
- Select an account from the menu in the ACCOUNT column.
- Select a property from the menu in the PROPERTY column.
- Under PROPERTY, click Tracking info > Tracking code.
Your Tracking ID is displayed at the top of the page.
Your Google tag is displayed farther down the page in a text box under Website Tracking > Google tag (gtag.js)
The Google tag
The Google tag is several lines of code that you need to paste into each webpage you want to measure:
<!-- Google tag (gtag.js) -->
... (several lines of code) ...
</script>
To add the Google tag to your webpages:
- Copy the entire contents of the text box.
- Paste it after the opening
<head>
tag on each page that you want to measure.
Set up data collection based on your type of site
The method of collecting data in Analytics varies depending on the type of website that you use:
Static website
A static website doesn't generate HTML using a programming language or interface like Python or PHP. To collect data, you need to copy and paste the Google tag into the source code on every webpage you want to measure.
- Find the Google tag for your property, and copy the code exactly without editing it.
- Paste your code (unaltered, in its entirety) after the opening
<head>
tag on each page that you want to measure.
Learn more about how to collect and send data from web pages to multiple Analytics properties.
Dynamic website
A dynamic website generates HTML using a programming language or interface like Python, PHP, etc. To collect data, include the Google tag in the source code for every web page you want to measure. You can use a common include or template to push the Google tag dynamically into every web page.
- Find the Google tag for your property and copy the code exactly without editing it.
- Paste your Google tag into its own include file.
- Link the include file so that the snippet appears after the opening
<head>
tag on each page that you want to measure.
If you’re using PHP:
- Find the Google tag for your property and copy the code exactly without editing it.
- Paste your Google tag into a file named 'analyticstracking.php'.
- Include the analyticstracking.php file on each PHP template page.
- For each template page, immediately after the opening <body> tag, add the following code:
<?php include_once("analyticstracking.php") ?>
Note that you can update the Google tag for dynamic websites more efficiently using Google Tag Manager.
Web-hosting service (you don't control the page code)
Some Internet Service Providers or hosting platforms (e.g. Wordpress, GoDaddy, Wix, Weebly) simplify Google tag installation by offering plug-ins that automatically install Analytics on your web pages.
Here are Analyticsbimplementation instructions for some common providers:
- GoDaddy
- Google Sites
- Magento
- Prestashop
- Shopify
- Weebly
- Wix
- Wordpress.com (for business)
Note that when you use a plug-in to collect data, you may not have the option of adding configuration settings to customise the data that you want to measure. If you have special requirements for measuring data, review how to get started with Analytics.
Website using Google Tag Manager
Google Tag Manager is a free tool to help add and manage multiple analytics and site-tracking tags. To use Google Tag Manager to install your Google tag, read the Google Tag Manager setup and installation guide.
Verify that your Google tag is working
To verify that the tag is working, visit your website, and then check the Real-Time reports in Analytics to verify that your visit was registered.
You can also use Google Tag Assistant to determine whether your tag is implemented correctly.
Download Tag Assistant | Learn more about using Tag Assistant