---
schema_version: "1"
id: 275fe4887aad00680c32d127bdf7b2cd13b0ca406f130e063edd0c08b3d06243
title: site:googleAnalyticsTracking
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/components/pages-compref-site-googleanalyticstracking.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-compref-site-googleanalyticstracking.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: a5ad5dcedb19251d742c76f65eb003179a90cdd750db2649e29f560a5207061b
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# site:googleAnalyticsTracking

The standard component used to integrate Google Analytics with Force.com sites to track and analyze site usage. Add this component just once, either on the site template for the pages you want to track, or the individual pages themselves. Don't set the component for both the template and the page. Attention: This component only works on pages used in a Force.com 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.

## Example

```apex

  	<!-- Google Analytics recommends adding the component at the bottom of the page to avoid increasing page load time. -->
	<site:googleAnalyticsTracking/>
```

The example above renders the following HTML:

```html

	<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	</script>
	
	<script>
		try {
  			var pageTracker = _gat._getTracker("{!$Site.AnalyticsTrackingCode}");
		
  			if ({!isCustomWebAddressNull}) {
   				pageTracker._setCookiePath("{!$Site.Prefix}/");
 			}
 		
 			else if ({!isCustomWebAddress}) {
	    		pageTracker._setAllowLinker(true);
    			pageTracker._setAllowHash(false);
    		}
    	  
   			else {
     			pageTracker._setDomainName("none");
     			pageTracker._setAllowLinker(true);
     			pageTracker._setAllowHash(false);
   			}
			pageTracker._trackPageview();
 		}  
 		catch(err) {
 		}
	</script>
```

## Attributes

|Attribute Name|Attribute Type|Description|Required?|API Version|Access|
|--------------|--------------|-----------|---------|-----------|------|
|`id`|String|An identifier that allows the component to be referenced by other components in the page.| |14.0|global|
|`rendered`|Boolean|A Boolean value that specifies whether the component is rendered on the page. If not specified, this value defaults to true.| |14.0|global|

