Mobile app version of vmapp.org
Login or Join
Gail5422790

: How to get multiple form field values in Google Analytics site search report? I'm wondering how I can get multiple form field values into Google Site Search. For instance, I have a search form

@Gail5422790

Posted in: #GoogleAnalytics #Php #Search #SiteSearch

I'm wondering how I can get multiple form field values into Google Site Search. For instance, I have a search form that has a drop down for year, make and model.

Once submitted I would like those three values to be submitted as one string to Google Site Search. My URL after submitting looks like mysite.com/index.php?s=1&year=2007&make=Toyota&model=Tundra

I have already created a query parameter in my Site Search Settings in Google Analytics called search. I just need help programmatically doing the rest.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

1 Comments

Sorted by latest first Latest Oldest Best

 

@Samaraweera270

You can push data to analytics on search results site loading that way:

analytics.js: ga('send', 'pageview', '/search_results.php?search='+make+' - '+model+' - '+year);


But you need to get GET params from URL. Example:

function get(key_str) {
if(window.location.search) {
var query = window.location.search.substr(1);
var pairs = query.split("&");
for(var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split("=");
if(unescape(pair[0]) == key_str)
return unescape(pair[1]);
}
}}

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme