开发者

GA not tracking subdomain which is Google Search Appliance

开发者 https://www.devze.com 2023-02-09 16:12 出处:网络
I have been using Urchin 6 but have just started to use Google Analytics also. I am also using Google Search Appliance for site search.

I have been using Urchin 6 but have just started to use Google Analytics also. I am also using Google Search Appliance for site search.

Search is on a subdomain i.e. www.search.mysite.com

The problem is that Google Analytics is tracking site search as a self-referral. After a lot of reading online I have ended up with the GA code configuration below which should be picking up the search subdomain but it isn’t. Can anyone see anything incorrect about my configuration? - E.g. is the GATC request process order correct

<script type="t开发者_运维知识库ext/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxx-1']);
  _gaq.push(['_setLocalRemoteServerMode']);
  _gaq.push(['_setLocalGifPath', '/__utm.gif']);
  _gaq.push(['_setDomainName', 'mysite.com]);  
  _gaq.push(['_addIgnoredRef', 'mysite.com']);  
  _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>

I have a suspicion that the issue could lie with the configuration of GA on Google Search Appliance. When you add GA it just asks for the UA code on the XSLT and you send up with the script below on each search page:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">
     <!--
  _uacct = "UA-xxxxxxx-1";
  urchinTracker();
  //--></script>

Could this be the problem or does this code need to change in the XSLT or maybe not?

Any help would be appreciated. Thanks


I don't have a complete answer for you, as I'm trying to work out some glitches myself. But maybe this will help suggest approaches.

I'm using version 6.8.0.G.30 of the search appliance.

I can insert my Google Analytics account number in the Analytics Account field under the "Global Attributes" section of the Page Layout Helper for the desired Appliance Front End.

That GUI approach has the effect of inserting the account number into the XSLT for that Front End:

<!-- *** analytics information *** -->
<xsl:variable name="analytics_account">UA-1234567-1</xsl:variable>

When the transformation is processed and the page is rendered, if a value is found for the account, then this JavaScript is generated in the search results page:

<script type="text/javascript" src="http://www.google-analytics.com/ga.js"></script><script type="text/javascript">
     var pageTracker = _gat._getTracker("UA-1234567-1");
     pageTracker._trackPageview();
   </script>

As an alternative to using the Page Layout Helper, you can "Edit underlying XSLT code" to manually edit the stylesheet and insert the analytics account.

The Google Analytics code produced by the default XSLT may not be what you want (probably isn't based on your post). For example, the snippet above is the synchronous version.

So, you'll probably want to edit the XSLT anyway to modify the snippet. I wanted to use the asynchronous snippet, so I changed the template named "analytics" used in the XSLT (that specifies to not customize):

<!-- **********************************************************************
 Analytics script (do not customize)
     ********************************************************************** -->
<xsl:template name="analytics">
 <xsl:if test="string-length($analytics_account) != 0">
   <script type="text/javascript" src="{$analytics_script_url}"></script>
   <script type="text/javascript">
     var pageTracker = _gat._getTracker("<xsl:value-of select='$analytics_account'/>");
     pageTracker._trackPageview();
   </script>
 </xsl:if>
</xsl:template>

That template is where the account information you've previously entered in the XSLT (via GUI or XSLT) gets substituted in. It's called at various locations in the Front End XSLT.

It's also possible to change the URL for the analytics script (you see that variable used in the "analytics" template).

What I did was to substitute the "analytics" template above with my own asynchronous version. So now when I look at the rendered search results, I see the async snippet there.

In my _setDomainName method, I have a leading period before the domain: .mysite.com which is consistent with the other Google Analytics-enabled pages on the rest of our site.

The "best practice" for this seems to be an area of some discussion: http://www.roirevolution.com/blog/2011/01/google_analytics_subdomain_tracking.php

Many of the comments on that post refer to self-referrals.

On the appliance search results page, the Google Analytics snippet appears immediately following the <body> tag.

The discussion of where to locate the asynchronous snippet (or "parts" if it's being split) has been raised in repeated forum posts:

http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=71ba44443f0bfbc3&hl=en

http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=22ac794d8f26a2f4&hl=en

This has been a pretty good reference for me on the asynchronous snippet:

Asynchronous Tracking Usage Guide: http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html

Moving the snippet to <head> would take me some thinking and a more thorough look at the XSLT (and probably tweaking that would be jeopardized with future appliance versions and potential XSLT changes)

In terms of debugging Analytics, I've started to focus on investigating the values of GA-specific cookies and the __utm.gif using Firebug and other similar browser tools.

This post:

http://blog.vkistudios.com/index.cfm/2008/12/17/Slicing-and-Dicing-Cookies--Part-2--Body-Parts

as well as its followup, and other pages at that site have really helped suggest an approach to troubleshooting.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号