0

I have a search functionality set up in my website, which uses a third party extension retrieve the search results. The search terms are not passed as query parameters.

Below is my sample URL for my search results: mysite.com/search/results/dGVzdA/

I cannot change the URL to pass the search terms as query parameters.

So I'm trying to send Async Tracking from the google analytics javascript :

<script>
var _gaq= _gaq || [];
_gaq.push(['_setAccount','UA-XXXXXXX-X']);
//Push search query into google analytics

if ({url_segment_1} == 'search' && {url_segment_2} == 'results') 
_gaq.push(['trackPageview'],['/search/?q=test']);
else
_gap.push(['trackPageview']);
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>   

The javascript logic seems to be executing fine, I've tested it by placing alert options. So is there anything that I'm implementing incorrectly with respect to _gaq.push(). Could someone throw light on the same

j0k
  • 22,600
  • 28
  • 79
  • 90
Adi GuN
  • 1,244
  • 3
  • 16
  • 38

1 Answers1

1

A couple of errors:

  • It's _trackPageview, with an initial underscore.
  • The argument for _trackPageview needs to be inside the array, like:

_gaq.push(['_trackPageview','/search/?q=test']);

[edit] There's also typo: _gap.push should be _gaq.push

mike
  • 7,137
  • 2
  • 23
  • 27
  • Thank you so much. I made the corrections. But still the site terms are not being logged. Will it take some time or it will be logged instantaneously? – Adi GuN Dec 20 '12 at 19:22
  • It can take a few hours (or more) for tracking data to start showing up. Note: By default, Google Analytics doesn't show today's data in it's reports. You can change the date rage to include the current date. – mike Dec 21 '12 at 15:45
  • Also, have you doublechecked for JavaScript errors using something like Chrome Developer Tools console, or FireBug console and Firefox? – mike Dec 21 '12 at 15:46
  • Yup it took few hours infact half a day for the data to be reflected. But its working like a charm now. Thanks – Adi GuN Dec 26 '12 at 20:33