Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Instructions to send clicks information using the Javascript Tagging Library.

Step-by-step guide

Click events should be triggered when any result is selected by the user in the search results page. At this moment, the function trackClick should be executed.

trackClick

Code Block
languagejs
trackClick(terms, page, position, productId, title, url, options, callback)


Parameters

ParameterDescriptionData TypeMandatory
termsThe query typed by the userStringYes
pageThe page number where user clicksInteger

Yes

positionThe position in SERP of the product selected.IntegerNo*
productIdThe product ID of the selected result.StringNo*
titleThe product or result title.String

Yes

urlDestination URL, for example product detail pageStringYes
optionsObject that may contain information about filters and other required dataObjectNo*
callbackFunction that will be executed after sending dataFunctionNo

*This parameters are not mandatory for the service but necessary for the statistics

Options

The options object should contains additional parameters not passed as parameters in function call:

...

Code Block
languagejs
{
	page: page,
	productId: productid,
	position: position,
	title: title,
    url: url,
    follow: false
}


Code samples

Code Block
languagexml
<a href="http://MY_PRODUCT_URL.com" title="My product title" class="myLink" prodID="prod_id">My Test Link</a>

...

Code Block
languagejs
/**
* 1 -> Capture click on the desired product
* 2 -> Avoid default action (redirect to destination url)
* 3 -> Execute trackClick function with the desired callback (including url redirection)
*/
jQuery('a#myLink').click(function(){
   event.preventDefault();
   var myURL = this.href;
   var title = this.title;
   var productId = this.prodID;
   var options = {
	    lang: LANGUAGUE,
		scope: SCOPE,
		section: SECTION,
		user: USER_ID,
		session: SESSION_ID
	};
	
   empathyTAG.trackClick('test',1,3, this.prodID, this.href, options, function(){
   		//Add your code here
   		document.location.href = myURL;
   });
});


Filter by label (Content by label)
cqllabel = "empathy-tag-api-javascript" and space = currentSpace ( )