Clear search
Close search
Google apps
Main menu

The instructions in this help article may be affected by recent changes in the Analytics user interface. See this blog post for details. Help center updates are coming soon.

Set up Analytics tracking

Find your tracking ID and tracking-code snippet

When you create an Analytics property, Analytics generates a tracking ID and a JavaScript tracking-code snippet specific to that property. To set up tracking (collect data) for that property, you usually need either the tracking ID or the tracking-code snippet. For example, some web-hosting services require only the tracking ID, and in other cases you need to add the entire code snippet to each web page you want to track.

To find the tracking ID and code snippet:

  1. Sign in to your Analytics account.
  2. Click Admin.
  3. Select an account from the menu in the ACCOUNT column.
  4. Select a property from the menu in the PROPERTY column.
  5. 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.
You need to add the tracking code to each page or screen from which you want to collect data.

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.

    1. Find the Javascript tracking-code snippet for your property, and then copy the entire snippet. Don't make any changes to the snippet.
    2. Paste the entire snippet into the HTML on your web pages, just before the closing </head>tag.

    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.

    1. Find the Javascript tracking-code snippet for your property, and then copy the entire snippet. Don't make any changes to the snippet.
    2. 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 </head>tag.

    Using PHP?

    Copy the Javascript tracking code snippet and add it to a file named analyticstracking.php. Then 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 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.

Was this article helpful?
How can we improve it?
Google Analytics training and support resources

Check out our comprehensive list to learn more about Analytics solutions.