Query Terms in URL

42 views
Skip to first unread message

Luke O'Sullivan

unread,
Jun 11, 2012, 5:15:20 AM6/11/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk
Hi Folks,

Our systems librarian would like to add search query terms to Xerxes's urls primarily so that Google Analytics can pick them up. Is there anyway to do this without modifying the core code?

Cheers,

Luke  

helix84

unread,
Jun 11, 2012, 5:32:40 AM6/11/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk
On Mon, Jun 11, 2012 at 11:15 AM, Luke O'Sullivan
<datavoy...@gmail.com> wrote:
> Our systems librarian would like to add search query terms to Xerxes's urls
> primarily so that Google Analytics can pick them up. Is there anyway to do
> this without modifying the core code?

Hi Luke,

since the search form is submitted using the GET method, this should
already work just fine. All you should need to do is set "Do track
Site Search" and enter "query" into the "Query parameter" field in GA.
(For some reason, I have "query2" there, but I didn't investigate
further because I'm not really using it).

Regards,
~~helix84

Luke O'Sullivan

unread,
Jun 15, 2012, 9:51:54 AM6/15/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk, hel...@centrum.sk
Hi,

Thanks for that! I''l pass the info on.

Cheers,

Luke


On Monday, 11 June 2012 10:32:40 UTC+1, helix84 wrote:
On Mon, Jun 11, 2012 at 11:15 AM, Luke O'Sullivan

Luke O'Sullivan

unread,
Jul 30, 2012, 5:30:15 AM7/30/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk
I've done a little more digging on this and I'm not sure the standard Google Analytics setup will work.

As I understand it, a html page (which would include the Google tracking code) is never generated with the raw query terms at ?base=metasearch&amp;action=search - rather Xerxes "intercepts" them and generates the metasearch hits page : "base=metasearch&amp;action=hits&amp;group=2012-07-30-000035"

Is this correct?

Walker, David

unread,
Jul 30, 2012, 9:05:12 PM7/30/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk

Yes, that’s right Luke.  Xerxes establishes the search with Metalib and then redirects the user to the search progress page.

 

You could include the query(s) and the field(s) in the redirect link.   If so, pass on a patch, we can include that.

 

--Dave

 

-------------------------

David Walker

Interim Director, Systemwide Digital Library Services

California State University

562-355-4845

--
You received this message because you are subscribed to the Google Groups "xerxes-portal" group.
To view this discussion on the web visit https://groups.google.com/d/msg/xerxes-portal/-/BzPHChCFrHkJ.
To post to this group, send email to xerxes...@googlegroups.com.
To unsubscribe from this group, send email to xerxes-porta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xerxes-portal?hl=en.

Luke O'Sullivan

unread,
Aug 1, 2012, 6:53:56 AM8/1/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk
Hi Folks,

I have the following in MetasearchHits.php

                         // redirect to merged results page

                        // Add search info to url (for use with Google Analytics)
                        $searchInfo = $this->getCache( $id , "search", "SimpleXML" );
                        $searchPairs = $searchInfo->pair;

                        $arrParams['query'] = (string) $searchPairs[0]->query;
                        $arrParams['field'] = (string) $searchPairs[0]->field;

                        if (isset($searchPairs[1])) {
                            $arrParams['query2'] = (string) $searchPairs[1]->query;
                            $arrParams['field2'] = (string) $searchPairs[1]->field;
                            $arrParams['operator'] = (string) $searchInfo->operator;
                        }
                         
                        $arrParams["resultSet"] = $strMergeSet;
                            
                        $this->cache->save();
                        $this->request->setRedirect( $this->request->url_for($arrParams) );
                         
                        return 1;

Are you happy with this approach or is there a better way to extract the query terms?

Also, would you like it to be wrapped in something which checks for a config setting addSearchTermsToResultsUrl or similar?

Thanks,

Luke


On Monday, 11 June 2012 10:15:20 UTC+1, Luke O'Sullivan wrote:

Walker, David

unread,
Aug 6, 2012, 2:56:06 PM8/6/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk

Hi Luke,

 

Instead of doing it here in the MetasearchHits command, it might be easier to instead do it on the MetasearchSearch command, since you can simply pass along the query and field from the incoming URL to the redirect action – there are already variables for this --rather than having to resurrect and parse the query out of the cache.

 

Make sense?

 

--Dave

 

-------------------------

David Walker

Interim Director, Systemwide Digital Library Services

California State University

562-355-4845

 

From: xerxes...@googlegroups.com [mailto:xerxes...@googlegroups.com] On Behalf Of Luke O'Sullivan
Sent: Wednesday, August 01, 2012 3:54 AM
To: xerxes...@googlegroups.com
Cc: a.t....@swansea.ac.uk
Subject: [xerxes-portal] Re: Query Terms in URL

 

Hi Folks,

--

You received this message because you are subscribed to the Google Groups "xerxes-portal" group.

To view this discussion on the web visit https://groups.google.com/d/msg/xerxes-portal/-/C5jKdTc11LMJ.

Luke O'Sullivan

unread,
Aug 7, 2012, 9:04:29 AM8/7/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk
Hi Dave,

The only problem I can think of with doing it in MetasearchSearch is that a "hit" will be recorded against Google analytics every time the MetasearchHits page is refreshed. Do you think that will be an issue? Otherwise, as you say, it's a lot easier!

Thanks,

Luke

Walker, David

unread,
Aug 7, 2012, 9:43:32 AM8/7/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk

Yeah, I was wondering about that, too.  Although a hit will recorded every time someone comes back to the search results page from viewing a full record, too, no?

 

I’ve never really used Google Analytics for tracking things like searches.  Do you have some control over how it works?

 

--Dave

 

-------------------------

David Walker

Interim Director, Systemwide Digital Library Services

California State University

562-355-4845

 

From: xerxes...@googlegroups.com [mailto:xerxes...@googlegroups.com] On Behalf Of Luke O'Sullivan


Sent: Tuesday, August 07, 2012 6:04 AM
To: xerxes...@googlegroups.com
Cc: a.t....@swansea.ac.uk

--

You received this message because you are subscribed to the Google Groups "xerxes-portal" group.

To view this discussion on the web visit https://groups.google.com/d/msg/xerxes-portal/-/TaOeFGSqWQQJ.

Luke O'Sullivan

unread,
Aug 9, 2012, 7:08:04 AM8/9/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk
Hi Dave,

It's clever enough to determine unique page visits vs page hits so it should be able to deal with issues surrounding returning to result / metasearch hits.

The only other reason I can think of not to do it the "easier" way is that it is nice to have the search terms on the actual results page.

Thanks,

Luke

Walker, David

unread,
Aug 9, 2012, 12:32:21 PM8/9/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk

I’ll let you decide, Luke, since you’re kind enough to do the coding.

 

Just send me a patch.

 

-------------------------

David Walker

Interim Director, Systemwide Digital Library Services

California State University

562-355-4845

 

From: xerxes...@googlegroups.com [mailto:xerxes...@googlegroups.com] On Behalf Of Luke O'Sullivan
Sent: Thursday, August 09, 2012 4:08 AM
To: xerxes...@googlegroups.com
Cc: a.t....@swansea.ac.uk
Subject: Re: [xerxes-portal] Re: Query Terms in URL

 

Hi Dave,

--

You received this message because you are subscribed to the Google Groups "xerxes-portal" group.

To view this discussion on the web visit https://groups.google.com/d/msg/xerxes-portal/-/RsNLN8GxNM0J.

Luke O'Sullivan

unread,
Aug 13, 2012, 5:22:00 AM8/13/12
to xerxes...@googlegroups.com, a.t....@swansea.ac.uk
Hi Dave,

Please find a patch for showing the query terms in the results page url. Though it's a little more complicated than using the MetasearchHits page, I went for MateasearchResults page in the end as I think it's the most appropriate place for showing the query terms. I've also included a config setting for turning the option on and off.

Thanks,

Luke
xerxesQueryTerms.patch
Reply all
Reply to author
Forward
0 new messages