This thread is a discussion for the wiki article: Google Analytics Site Search
   
 
Google Analytics Site Search
Posted: 28 April 2009 06:19 AM   [ Ignore ]  
Research Assistant
RankRankRank
Total Posts:  342
Joined  12-17-2008

Obviously this method will not record search terms which have no matches as the “Your search did not return any results” template does not contain the GA.js code.

How do you get Google Analytics Site Search to record search keywords that do not match any entries?

Profile
 
 
Posted: 07 May 2009 10:17 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  258
Joined  09-16-2004

I’m trying to put Google Analytics code in place to track searches on my site, as per the instructions in the Wiki article.

I have the following in place in my search results template (at /search/results/) (the forum will have removed some parts of it, of course)

[removed]
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." "http://www.");
[removed](unescape("<script src='" gaJsHost "google-analytics.com/ga.js' type='text/javascript'></script>"));
[removed]

[removed]
var pageTracker _gat._getTracker("UA-XXXXXX-XX");
pageTracker._initData();
terms='{exp:search:keywords}';
searchterms=terms.toLowerCase().replace(/\s/g,'+');
pageTracker._trackPageview('/search?q='+searchterms);
[removed] 

With the correct account number in place of XXXXXX of course.

It’s been in place for over a week now and yet isn’t tracking any searches at all. Analytics reports no searches having taken place, though I know they have - I’ve been doing loads to see the results, and there are lots being reported in the CP search logs.

Can anyone see what I’m doing wrong here? My regular Analytics code looks like this:

[removed]
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." "http://www.");
[removed](unescape("[removed][removed]"));
[removed]
[removed]
try {
var pageTracker _gat._getTracker("UA-XXXXXX-XX");
pageTracker._trackPageview();
catch(err{}[removed] 

which looks a little different. I’m going to try and adapt the search code a bit more, but any help in the meantime really appreciated.

Thanks.

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 12 May 2009 11:30 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  507
Joined  03-21-2006

It looks like something has gone squiffy with the escaped code in the Wiki article. The codes for < and > have been corrupted in the unescape function call.

What they are:

< : &#x3C;
> : &#x3E; 

What they should be:

< : %3C
> : %3E 

Hope that helps.

Cheers,
Stephen

 Signature 

Stephen Lewis |  EE Addons  |  Twitter  |  Custom EE Addon Development

Profile
 
 
Posted: 12 May 2009 04:42 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  258
Joined  09-16-2004

Ooh this looks promising - I hadn’t spotted that those had been mangled. Thanks Stephen - I’ll keep an eye on Analytics to see if it tracks searches now.

 Signature 

Definition // Simply effective websites - web design based in Hull and East Yorkshire

Profile
 
 
Posted: 10 July 2009 01:41 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  4
Joined  07-05-2009

I’m starting to check on applications and basically I want the Google Analytic Site. Any idea how to add up on the website? I’m under self learning process of creating a website.

So I am also looking for some tools. Under this site it says about content management. Errr… still also in a process of gathering good content. Doing one thing at a time I guess..

Profile
 
 
Posted: 12 July 2009 09:58 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  4
Joined  07-05-2009

I started reading the link for Google Analytic Site. My question is, does the website that has to be analyzed must be owned by me. Or is’t possible to include an existing website which is not in my ownership? I haven’t started yet. I’m still reading stuff here from Google. It’s really interesting and has a lot of information.

Profile
 
 
Posted: 27 July 2009 09:49 AM   [ Ignore ]   [ # 6 ]  
Summer Student
Total Posts:  1
Joined  07-27-2009

I really don’t understand these codes…so if I need to understand these then is there any basic thing which I should be reading??

Profile
 
 
Posted: 11 March 2010 02:46 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  1
Joined  03-11-2010

When the virtual page is generated for Keyword site search tracking, does this page count as an additional page view in Google Analaytics?

Profile