Set up Analytics tracking
Find your tracking ID and tracking-code snippet
To find the tracking ID and code snippet:
- 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 displayed at the top of the page.
- Information about tracking apps is displayed under Mobile app tracking - Using the SDK.
- The tracking-code snippet for your website is displayed under Website tracking.
Find the setup for the type of property you're tracking
There are several ways to collect data from online properties in Analytics, depending on whether you want to track a website, an app, or some type of Internet-connected device. The following methods explain how to set up the tracking code for different types of properties.
- Static website
A static website is based on HTML that doesn't change dynamically, and is NOT generated using a programming language like Python, Ruby, or PHP.
- Paste the entire snippet into the HTML on your web pages, just before the closing
If you want to send data from a single page to multiple properties, you can track a page using multiple accounts or multiple properties within a single account.
- Dynamic website
A dynamic website is one for which the HTML is generated using a programming language like Python, Ruby, or PHP. You can use an include statement or template to push the tracking code dynamically to each page.
- Paste the entire snippet into its own include file, then add the include statement to your page header so that the snippet appears before the closing
analyticstracking.php. Then include the
analyticstracking.phpfile 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 tracking code for dynamic websites more efficiently using Google Tag Manager.
- Web-hosting service (you don’t manage the source code)
Some Internet service providers or hosting platforms (such as Wordpress, GoDaddy, Wix, Weebly, etc.) simplify Analytics tracking-code installation by offering plug-ins that automatically install it on your web pages. Review your platform’s instructions to add your Analytics tracking ID.
Here are the Analytics implementation instructions for some common providers:
When you use a plug-in to collect data, you may not have the option of adding configuration settings to customize the data you want to track. If you have special requirements for tracking data, review how to get started with Analytics.
- Website using Google Tag Manager
Google Tag Manager is a free tool you can use to manage multiple analytics and site-tracking tags. To use Google Tag Manager to install your Analytics tracking code, read the Google Tag Manager setup and installation article.
- Mobile app
- Internet-connected device or CRM system
To collect data from an Internet-connected device such as online point-of-sales system or video-game console, or from a CRM system or other platform, you need to use the Analytics Measurement Protocol.
Verify that your tracking code is working
Once you have successfully installed the Analytics tracking code, it can take up to 24 hours for data such as traffic-referral information, user characteristics, and browsing information to appear in your reports. However, you can check your web-tracking setup immediately.
The Google Developers site is a great resource to learn more about how the tracking-code snippet works.