For Google Analytics (what I use):
Analytics Settings --> Profile Settings --> Click Edit (top right)
Site Search
--> Do Track Site Search
--> Query Parameter (required):
AS_search
--> No, do not strip query parameters out of URL
--> Do you use categories for site search?
No
----------------------------------------
First we make the search (from template) and then go to landing page/search-results.html
---> Then we refresh the page!
1. Create TVs and use in template: <head>[*head*]</head> <body[*body*]>
2. Create 2 snippets:
getsearch
<?php
$getsearch = '?AS_search=' . strip_tags($_POST['search']);
return $getsearch;
?>
onload
<?php
if (isset($_POST['search'])) {
$onload = ' onload="getget();"';
}
else {
$onload = '';
}
return $onload;
?>
3. Edit landing page/search-results.html:
head
<script type="text/javascript">
/* <![CDATA[ */
function getget()
{
location.replace("[~[*id*]~][!getsearch!]");
}
/* ]]> */
</script>
body
Seems to be working. Without using the onload snippet it made a loop.
Now it stops if there if no search word submited to $_POST.
I know people are voting to get AjaxSearch forms to use
$_GET but this is a workaround. It doesn’t need any modification to
the tpl forms. The downside is the refresh (or the new search using $_GET)... but even ajax loaded
websites does this all the time...
Original thread:
http://modxcms.com/forums/index.php/topic,41371.0.html