-
- 126 Posts
I notice the Ajax search doesnt show a query parameter in the results after you search. It seems to only use parameters after you click.
I would like to use a query parameter in the URL after you search so I can track the site search with Google Analytics.
Any Suggestions?
-
- 2,877 Posts
I can track searches made by GET requests,
$_GET[’AS_search’]
...url?
AS_search=Something
In GA I just set: AS_search
But yes AjaxSearch forms just uses POST.
I have used a very different approach but
<form id="ajaxSearch_form" action="search-results.html?AS_search" method="post">
Maybe is simple enough.
-
- 126 Posts
Does this mean I can not achieve it using AjaxSearch?
Or is using Get requests a config option of Ajax search?
-
- 2,877 Posts
I just edited my comment above. When trying it takes hour for it to show up in GA.
So for testing one could set up a snippet on the result page to see if that makes it store in
GET too. Have no time now to test!
-
- 126 Posts
I get the Gist of what you are doing here,
But where in the Ajax searc can I change <form id="ajaxSearch_form" action="search-results.html?AS_search" method="post">
Is it in the snippet or one of the templates?
Stuart
-
- 2,877 Posts
Depends on what template you use... so why not change them all!
THIS WORKS BTW!
//
http://modxcms.com/forums/index.php/topic,31668.msg246656.html#msg246656
-
- 2,877 Posts
I’m sorry for misleading you guys!!
This worked for me ONLY because I was using a plugin (404)...
Now I’m trying this:
[[getsearch]]:
<?php
$getsearch = '?AS_search='.$_POST['search'];
return $getsearch;
?>
In form:
<form [+as.formId+] action="[+as.formAction+][[getsearch]]" method="post">
IT DOESNT WORK YET!
No snippet is needed this do the same thing:
<form [+as.formId+] action="[+as.formAction+]?AS_search=[+as.inputValue+]" method="post">
It only works if the form gets re-submited...
Once again sorry...
-
- 2,877 Posts
BUT I can use searched as GA parameter because I use the higligther plugin.
That way I can get stats of what results got clicked on at least...
-
- 126 Posts
But CLicked on is not so good. Doesnt really let Google Analytics handle the data the way it should.
There should be a really easy solution to get that parameter pass the first time the search happend.
Anyone?
-
- 2,877 Posts