: 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
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.
More posts by @Gail5422790
1 Comments
Sorted by latest first Latest Oldest Best
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]);
}
}}
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.