Salesforce Sites provides out-of-the-box integration with Google Analytics. To track the usage of your sites and site pages, use Google Analytics. You can track the number of visits, the number of page views, the average time spent on the site, and more.
Required Editions
| Available in: both Salesforce Classic and Lightning Experience |
| Available in: Developer, Enterprise, Performance, and Unlimited Editions |
| User Permissions Needed | |
|---|---|
| To create and edit Salesforce Sites: |
Customize Application OR Create and Set Up Experiences |
Note The
<site:googleAnalyticsTracking/>
component only works on pages used in a Salesforce Site. Sites must be enabled for
your organization and the Analytics Tracking Code field must be
populated. To get a tracking code, go to the Google Analytics website.- Sign up for an account at Google Analytics.
- Add a profile in Google Analytics and enter the domain or full URL for the site you want to track.
-
Copy the Web Property ID from Google's tracking status
information. Then paste that value into the Analytics Tracking
Code field on the Site Edit page for the site that you want to
track.
The Web property ID starts with the letters UA followed by your account and profile numbers. For example, UA-9049246-2.
- Save your changes.
-
To track the Visualforce pages associated with your site, enter the following
tag in the site template for those pages, or in the individual pages
themselves.
<site:googleAnalyticsTracking/>For a page to be tracked, this tag is required either in the page or the associated page template. The default site template already contains the tag, so all pages that use that template are tracked—including certain default pages.
Note Google recommends adding the component at the bottom of the page to avoid increasing page load time. -
Go to the Google Analytics site and follow their instructions for completing
the process.
After you sign up, it can take up to 24 hours before you see initial tracking results in Google Analytics.
Tip To track multiple sites separately, create separate profiles using the
full site URLs and enter a different Web property ID in the Analytics
Tracking Code field for each site.