Set up the web tracking code
Add basic page tracking to your website.
Follow these instructions to collect basic page tracking data from a website. Once you have successfully installed basic page tracking on your site, you'll see data in most of your Google Analytics reports, including traffic referral information, user characteristics, and browsing information. It may take 24 hours for data to appear in your reports once tracking has been installed.In this article:
Decide how to add tracking
There are two ways to collect page tracking data:
- Add the Google Analytics tag (Universal Analytics) to your website container using Google Tag Manager. This approach is recommended because using Google Tag Manager simplifies tag management on your site. Using Google Tag Manager makes it easier to add other tags (such as AdWords Conversion Tracking and remarketing tags) to your site and configure your Google Analytics tracking.
- Add the tracking code directly into the HTML of every page of your website. This is the easiest approach if you only want to add the basic Google Analytics tracking code to your site.
Add tracking using Google Tag Manager
If you are unfamiliar with Google Tag Manager, begin by reading About Google Tag Manager. Once you're ready to set up a Google Tag Manager account and set up Google Tag Manager on your site, read Setup and Workflow (Web).
To add Google Analytics tracking to your site, add the Google Analytics tag to your container in Google Tag Manager and publish the container.
Add the tracking code directly to your site
To complete this process, you must have access to your website source code, be comfortable editing HTML (or have a webmaster/developer who can help you), and have a Google Analytics account and property already set up.
To set up the web tracking code:
- Find the tracking code snippet for your property.
Sign in to your Google Analytics account, and select the Admin tab. From the ACCOUNT and PROPERTY columns, select the property you’re working with. Click Tracking Info > Tracking Code. Click to expand this image and see where these options appear in the interface.
<script>and ends with
The tracking code contains a unique ID that corresponds to each Google Analytics property. Don’t mix up tracking code snippets from different properties, and don’t reuse the same tracking code snippet on multiple domains.
- Copy the snippet.
Don’t edit your snippet. Just copy it. You might want to paste it into a text document if you’re worried about accidentally losing or changing the snippet from your clipboard.
- Paste your snippet (unaltered, in its entirety) into every web page you want to track. Paste it immediately before the closing
If you use templates to dynamically generate pages for your site (like if you use PHP, ASP, or a similar technology), you can paste the tracking code snippet into its own file, then include it in your page header.
Verify the tracking code is working as you expect
Check out strategies and tools that you can use to make sure that your tracking code is firing and that Google Analytics is reporting the data that you expect.
Refer to Introduction to analytics.js to learn more about Google Analytics tracking code.
Refer to the Google Analytics (Universal Analytics) tag if you use Google Tag Manager to manage your Google Analytics tracking.