function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SidharthSidharth 

Integrate Salesforce with Google Analytics

Hi All

 

I am trying to track my Salesforce Site, by using Google Analytics.

 

My Site URL is : www.fdrclient.com
I added the tracking code to this page, and i am able to track it successfully.

 

Now the problem is, when a Client enters Username and Password in this Site, it redirects the user to my VisualForce Page
www.fdrclient.com ------> https://na5.salesforce.com/home/home.jsp

 

I want to track this VisualForce page(home.jsp) also.
I added <site:googleAnalyticsTracking/> to the end of VisualForce page, but still i am not seing anything in the Google Analytics.

 

Any idea, what should i do?

 

Thanks
Sid

Best Answer chosen by Admin (Salesforce Developers) 
NikuNiku

Hello Sidh,

 

 You need to add this tag in the head section of the visual force Pages . for which you want to track the visits.

Or 

You can add the JavaScript provided to your site by Google analatic in the head section.  But in both cases it will take 24 hours to activate by google.

 

Recently i have done this work .. If it helps please mark as solved.

All Answers

SidharthSidharth

Actually, we not using Force.com Sites.

We just using the Customer Portal, so how can we integrate Google Analytic with it?

NikuNiku

Hello Sidh,

 

 You need to add this tag in the head section of the visual force Pages . for which you want to track the visits.

Or 

You can add the JavaScript provided to your site by Google analatic in the head section.  But in both cases it will take 24 hours to activate by google.

 

Recently i have done this work .. If it helps please mark as solved.

This was selected as the best answer
mikefitzmikefitz

He is right. You will need to add the google analytics snippet found below

 

http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html

SidharthSidharth

Thanks for your time.

 

Niku: Are your VF pages part of Force.com site?

 

I think it wont work, until that VF page is a part of a site. In my case, my organisation isnt using any Force.com site due to which i am unable to Copy the Web Property ID from Google's tracking status information and paste it into the Analytics Tracking Code field on the Site Edit page.

 

And if I put the tracking code in the head section of VF Page, how should VF URL specify it in the Google Analytic Website URL.

Ex this is my page:

 

<apex:page >
<head>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27204xxx-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src=('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

</head>
</apex:page>

 URL: https://cs1.salesforce.com/066S00000000XX

 

According to you, it should be tracked down by Google Analytic?

SidharthSidharth

It worked. Thanks Guys.


Sidharth wrote:

Thanks for your time.

 

Niku: Are your VF pages part of Force.com site?

 

I think it wont work, until that VF page is a part of a site. In my case, my organisation isnt using any Force.com site due to which i am unable to Copy the Web Property ID from Google's tracking status information and paste it into the Analytics Tracking Code field on the Site Edit page.

 

And if I put the tracking code in the head section of VF Page, how should VF URL specify it in the Google Analytic Website URL.

Ex this is my page:

 

<apex:page >
<head>

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-27204xxx-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src=('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

</head>
</apex:page>

 URL: https://cs1.salesforce.com/066S00000000XX

 

According to you, it should be tracked down by Google Analytic?


 

NikuNiku

Keep It up dude.

Nik's.

NehaVNehaV
Hi, Sidhu I want to tintegrate my salesforce site with Google analytics Can you please guide me how to do it. can you please share me the code which you used Thanks in advance Neha
Himanshu Rana 7Himanshu Rana 7
This post will help  you open the below link to know how to integrate google analytics with salesforce
http://himanshurana.in/google-analytics-report-visualforce-page/