Yesterday, saw a twitter from @omtrdeveloper about tracking Google Site Search in Omniture. This reminded me that I needed to do that for our site, except we do not use the Google Site Search, we use the Google Mini Search Appliance.
Here are the steps I took to integrate/capture the search terms into Site Catalyst.
Step 1. Locate and backup your searchtemplate.xslt file.
Step 2. In the section of the code that has the sections labeled “(can be customized)” add this code block.
<!-- ********************************************************************** Omniture SiteCatalyst code (can be customized) ********************************************************************** --> <xsl:template name="sitecatalyst"> <xsl:param name="query"/> <xsl:param name="matches"/> <xsl:comment> SiteCatalyst : Google Mini Search Integration </xsl:comment> <script language="JavaScript" type="text/javascript" src="INSERT-DOMAIN-AND-PATH-TO-CODE/s_code.js"></script> <script language="JavaScript" type="text/javascript"> <xsl:comment> s.eVar1="<xsl:value-of select='$query'/>" var s_code=s.t();if(s_code)document.write(s_code) </xsl:comment> </script> <script language="JavaScript" type="text/javascript"> <xsl:comment> if(navigator.appVersion.indexOf('MSIE')>=0) document.write("unescape('%3C')+'!-'+'-'") </xsl:comment> </script> <xsl:comment> End SiteCatalyst : Google Mini Search Integration </xsl:comment> </xsl:template>
NOTES:
1. Replace the”INSERT-DOMAIN-AND-PATH-TO-CODE” with the location where you uploadedthe s_code.js file:
2. Be sure to use an absolute path. http://www.rudishumpert.com/subfolder/s_code.js
3. Code above assumes you are using s.prop1. Change value as needed.
Step 3. Next, locate the XSL template named, search_results.
<!-- ********************************************************************** Search results (do not customize) ********************************************************************** --> <xsl:template name="search_results"> ... ... <body onLoad="resetForms()" dir="ltr">
and place the following code opening <body> tag:
<!-- *** Add Omniture SiteCatalyst code *** --> <xsl:choose> <xsl:when test="RES"> <xsl:call-template name="sitecatalyst"> <xsl:with-param name="query" select="Q"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="sitecatalyst"> <xsl:with-param name="query" select="Q"/> </xsl:call-template> </xsl:otherwise> </xsl:choose>
Step 4. Deploy code to test/production making sure to backup a copy of your existing XSLT template (just in case).
You should now be able to see the search terms being passed to Omniture using your debugging tool of choice.
-Rudi
EDIT: changed the Omniture variable used from prop1 to evar1 so we could add sub relations to the element.