X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Internal Site Search Data in Google Analytics (https://forum.x-cart.com/showthread.php?t=56095)

kwaterman 10-19-2010 09:39 PM

Internal Site Search Data in Google Analytics
 
Hi There
Brand new member to the forums here posting for the first time - hoping someone has some experience with this as I've spent a lot of time banging my head against this particular wall. :?

I'd like to be able to track internal site search terms within Google Analytics, but so far am having no luck. It looks like the analytics data is looking for a particular query parameter like a "q" or "s", but of course the search results URL doesn't show this type of thing - only http://www.domainname.com/search.php?mode=search&page=1". Does anyone know what changes I'd need to make, and to which template files? I have the latest Asynch GA code already in place.

Thanks very much!
Kathy

Jayk 06-17-2011 02:09 PM

Re: Internal Site Search Data in Google Analytics
 
Hi Kathy,

Did you ever figure this one out?

Thanks,
Jason

Acquamarina 02-02-2012 06:52 AM

Re: Internal Site Search Data in Google Analytics
 
Found this through another post. The code is very different on 4.4.4. Will it work?

http://www.squeezejuicemarketing.com/blog/capture-site-search-terms-in-x-cart-w-google-analytics/

qualiteam 02-06-2012 02:19 AM

Re: Internal Site Search Data in Google Analytics
 
Quote:

Originally Posted by Acquamarina
Found this through another post. The code is very different on 4.4.4. Will it work?

http://www.squeezejuicemarketing.com/blog/capture-site-search-terms-in-x-cart-w-google-analytics/


For 4.4.x you can try altering the "skin/common_files/modules/Google_Analytics/ga_code.tpl" template and replace this code:
Code:

pageTracker._trackPageview();
with this:
Code:

{if $main eq "search"}
  searchterms='{$search_prefilled.substring|escape}';
  searchterms=searchterms.toLowerCase().replace(/\s/g,'+');
  pageTracker._trackPageview('/search?q='+searchterms);
{else}
  pageTracker._trackPageview();
{/if}


The second step (from the reported instructions) is still required.

Acquamarina 02-06-2012 04:40 AM

Re: Internal Site Search Data in Google Analytics
 
Thanks, Alex, I'll do the changes and report back tomorrow.

Acquamarina 02-06-2012 04:50 AM

Re: Internal Site Search Data in Google Analytics
 
Forgot to ask - the query parameter is "q", as in the fix from squeezejuice?

qualiteam 02-06-2012 04:55 AM

Re: Internal Site Search Data in Google Analytics
 
Quote:

Originally Posted by Acquamarina
Forgot to ask - the query parameter is "q", as in the fix from squeezejuice?


Yes

Nacho 03-03-2012 11:37 PM

Re: Internal Site Search Data in Google Analytics
 
Thanks Alex,

What about if we are using GA Async mode?

What should be the change in this case?

Regards,

Nacho.

qualiteam 03-06-2012 02:56 AM

Re: Internal Site Search Data in Google Analytics
 
The regular async script looks like this:
Code:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _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 suppose you use 4.0.x, thus in skin1/customer/home.tpl before the Google tracking code appears, add this:
Code:

{if $main eq "search"}
  {assign var="searchterms" value=$search_prefilled.substring|escape};
{/if}


Change the tracking code like this:
Code:

<script type="text/javascript">

  searchterms = '{$searchterms}'.toLowerCase().replace(/\s/g,'+');

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  if (searchterms) {
    _gaq.push(['_trackPageview', '/search?q='+searchterms]);
  }
  else {
    _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>


Nacho 03-06-2012 03:03 AM

Re: Internal Site Search Data in Google Analytics
 
Thanks Alex, but my question was for x-cart version 4.4.5 :(


All times are GMT -8. The time now is 10:32 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.