1

I am trying to get google analytics site search to pull results submitted through my site's super search. I saw a post in the forums that I am supposed to change my form action from "post" to "get". This appears to be working as it creates the "?" that GA seems to depend on, however the url is pretty nasty with the XID=1232321 included. Is this XID necessary, or is there a way to remove this? If so, how would I remove it?

current url

/search/results?XID=25454320fc0a3329123123f8d496b5591fb4add&keywords=test

preferred url exmple

/search/results?keywords=test

Thanks for any information you can provide.

UPDATED

<div id="search">
    <form method="get" action="{path=search/results}">
        <input type="text" name="keywords" id="keywords" placeholder="Search" class="typeahead">
        <input type="submit" class="hidden-submit" />
    </form>
</div>
4

The XID (csrf_token in EE 2.8+) is used in POST forms to secure form submissions. A quick test shows that the XID isn't required for GET form submissions, so you can remove this from your GET form without running into issues.

If you're using {exp:super_search:search} in your search form, the XID field is provided for you (it's a hidden field), and the only way to get rid of it is to turn off secure forms in EE. However, this is not recommended to disable secure forms in EE as this disables secure forms for all forms on your site (from 3rd-parties or native EE).

The other solution is to keep secure forms enabled in EE, and to not use {exp:super_search:search}: it's not required for the functioning of the search form. If your form was a POST form, you would need to add the following field in your form:

<input type="hidden" name="XID" value="{XID_HASH}" />

However, if your form is a GET form, you don't need to add this field, and search should run fine and without throwing any errors about a missing XID.

| improve this answer | |
  • Does this also break the {super_search_keywords} variable? It no longer seems to be working, does this rely on being a POST or having an XID? Seems like it shouldn't as keyword param is still obviously passed. What am I missing here? – Thomas Jan 13 '15 at 14:49
  • More importantly, my search also no longer works, I was so cued in on formatting that I didn't even notice. The search simply returns all results no matter what term I use. – Thomas Jan 13 '15 at 16:03
  • 2
    Figured this out, I missed the note in the forums where your are required to add '/search' to the end of the form action. This solves both problems. I didn't see this in the docs, so if its not there, my be good to add to the docs as well. – Thomas Jan 13 '15 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.