Click tracking

Products returned from the Hello Retail product recommendation and search apis will contain links that have a tracking code appended to them in the fragment part of the url.

Example for search

Example for product recommendations

This tracking code allows the Hello Retail script to track clicks on products in search and recoms. When the api’s are used by the Hello Retail script these tracking links will be used in the generated dom. But a click handler is implemented so that the actual url that the customer is sent to when clicking the link does not contain the tracking fragment.

If you use the api directly you can leave the tracking fragment on the product urls. This will allow the Hello Retail script to automatically track clicks on the product recommendations or search implemented using our api solution.

Tracking without using the fragment

If you do not want to have the tracking fragment shown on the page the user lands on or the fragment does not work with your shop platform you can remove the fragment from the url. If you do this you will have to add a click handler to the products in your product recommendations or search. This click handler will make sure that click tracking is sent to Hello Retail even if the tracking fragment is not on the link. The click handler must set a cookie with the name “aw_source” and the value from the fragment in the tracking link. A bare bones implementation of this could look something like this:

<a href="" onclick="document.cookie='aw_source=pb-5cb4857e6ff3911d1c76ab6a';"> Awesome product </a>

You could consider implementing a click handler that finds the tracking fragment in the href attribute, sets it as a cookie and then navigates to the url without the tracking fragment.

Verify tracking

To verify that the click tracking works you can click one of the links that should track clicks with the network tab open in the browser developer console. The Hello Retail javascript will request the url. If tracking a search or product recommendation click that request should include clickedProductBoxId or clickedPartnerSearchConfigKey with the value from the tracking fragment.