Internal search engine

 

Foreword

Before starting implementation of internal search engine plugin, please ensure that you have initialised the AT Internet JavaScript tracker and selected the plugin from the Tag Composer interface.

 

Principle

The objective of this plugin is to allow the measurement of internal searches on your site.

 

Plugin settings

The internal search engine plugin can be set up from within the Tag Composer interface:

  • Query string variables for keywords entered: Automatically retrieves the keywords entered during the search in this variable
  • Query string variable for the page number: Automatically retrieves the results page number in this variable
  • Query string variable for the position of clicked result: Automatically retrieves the position of the clicked result found in this variable
  • Automatic click management: : When a click triggers navigation or a redirection, browsers prevent the measurement of these links. This automatic management enables measurement to be forced.
  • Automatic click management timeout: : Time after which automatic click management will force the navigation, even if measurement could not be completed (in milliseconds).
 

Tagging

To tag your searches, the tracker exposes an internalSearch object which in turn provides 2 methods::

  • set : used with the dispatch method of the tracker
  • send : sporadic measurement during an event

These methods are described in more detail in the Tracker’s operating principles

Parameters

Property Description
keyword Keywords entered during the search
resultPageNumber Page number of the results page (‘0’ if no result available)
resultPosition Position of the element on which the user clicked

Optional parameters (only for send method)

Property Description
elem Tagged DOM element
event JavaScript event (prevent event propagation) – since v5.7.0
callback Function to execute – since v5.7.0
 

Tagging examples

 

Tagging a search (the user is redirected to a screen containing the results)

var tag = new ATInternet.Tracker.Tag();

tag.internalSearch.set({
	keyword:'mySearch',
	resultPageNumber:'2'
});
tag.page.set({name:'Search_result_page'});
tag.dispatch();
 

Examples of tagging of a results link

If the tagging information is available during the click (keyword/page number of the results page/position of the element clicked within the results).

<script type="text/javascript">
    var tag = new ATInternet.Tracker.Tag();
</script>
<a href="http://www.site.com" onclick="return tag.internalSearch.send({elem:this,keyword:'mySearch',resultPageNumber:'2',resultPosition:'11'});">
    Product
</a>

If this information is only available on the landing page, just add the following tagging to the page in question:

var tag = new ATInternet.Tracker.Tag();

tag.internalSearch.send({
	keyword:'mySearch',
	resultPageNumber:'2',
	resultPosition:'11'
});
 

Tagging a search (using query string variables)

  • Set up the variables which must be automatically retrieved in the URL (2 possibilities)
    • Via the Tag Composer interface (preferred when different search pages are available on the site)
      • Variable query string for the keywords entered (eg.: indicate “kw” for keyword)
      • Variable query string for the page number (eg.: indicate “pagenum” for the page number)
    • Via the initialisation of the tag (preferred when only one search page is measured)
var myConfig = {
	InternalSearch : {
		urlKeyword:'kw',
		urlResultPageNumber:'pagenum'
	}
}
var tag = new ATInternet.Tracker.Tag(myConfig);
  • Tag the page with the query string variables

Example URL for the above configuration:

http://www.site.com/?kw=mySearch&pagenum=2

Research data is automatically sent when the page is hit:

tag.page.set({name:'Search Page'});
tag.page.dispatch();

The data tagged via the internalSearch.set/internalSearch.send methods takes priority over the data retrieved from the URL

It is possible to replace the “?” with a “#” to avoid referencing the searches

Was this post helpful?
Yes
No
Last update: 10/04/2018