Setting Up Your Store's Data with Searchspring:
1. Prepare | » | 2. Connect | » | 3. Fields | » | 4. Settings | » | 5. IntelliSuggest | » | 6. Analytics |
This article describes the process for setting up IntelliSuggest page tracking.
The instructions that follow are meant to be a generic guideline, suitable to be translated into any E-Commerce Platform. For our platform-specific instructions, see one of the following articles:
- 3dcart
- BigCommerce Blueprint
- BigCommerce Stencil
- CommerceV3
- Magento 1
- Magento 2
- MIVA
- Shopify
- Volusion
If your cart isn't listed above, please continue to follow the instructions below.
Be sure to replace the placeholder examples with the appropriate values (e.g., "YOUR_SITE_ID")
Your Searchspring Account Site ID may be found under "My Account" in the top right of the Searchspring Management Console.
The Shopper ID value should be the user ID for the current customer when they're logged in. If the customer is not logged in, it can be omitted. This value allows Searchspring to track shopper activity across devices.
Product Views (Product Detail Page)
Placing the script just before the closing </body>
tag works best for user experience/performance.
The SKU argument to the viewItem() should be the unique SKU or product code for that item.
The SKU passed here should be the same field as the SKU from your Core Fields setup. If you change the SKU field in Core Fields or in this tracking, be sure to also change both to match. Failure to do so can result in Product Recommendations and Product Insights features breaking for your site.
<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
var product_code = "YOUR_PRODUCT_SKU";
IntelliSuggest.init({siteId:'YOUR_SITE_ID', context:'Product/' + product_code, seed:[product_code]});
IntelliSuggest.setShopperId('THE_SHOPPER_ID'); // add user id here if customer is logged in, must be after 'init' call
IntelliSuggest.viewItem({sku:product_code});
} catch(err) {}
</script>
Basket Contents (Basket or Cart Page)
Placing the script just before the closing </body>
tag works best for user experience/performance.
One or more haveItem() calls are allowed. Include a haveItem() call for each item the shopper currently has in their basket. Don't worry about figuring out what they have most recently added or removed - always include all of the items currently in the basket.
The SKUs tracked on your Basket Contents page should match the SKU tracked on the Product View page. In most cases, this would be the parent product SKU.
Tracking Child SKUs / Variants
childSku can be passed in addition to sku for better tracking and performance of other Searchspring features. If you pass only childSku, the event will be included for Personalized Recommendations, but completely ignored for Searchspring reports and other features.<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
IntelliSuggest.init({siteId:'YOUR_SITE_ID', context:'Basket', seed:['ABC123','1000C','8ZYX300']});
IntelliSuggest.setShopperId('THE_SHOPPER_ID'); // add user id here if customer is logged in, must be after 'init' call
// Loop through products in cart
IntelliSuggest.haveItem({sku:"ABC123", qty:"1", price:"107.95"});
IntelliSuggest.haveItem({sku:"1000C", childSku:"400-XYZ", qty:"1", price:"20.00"});
IntelliSuggest.haveItem({sku:"8ZYX300", qty:"1", price:"7.63"});
IntelliSuggest.inBasket({});
} catch(err) {}
</script>
Sale (Order Confirmation Page)
Placing the script just before the closing </body>
tag works best for user experience/performance.
The inSale() information arguments are all optional.
The SKUs tracked on your Order Contents page should match the SKU tracked on the Product View page. In most cases, this would be the parent product SKU.
Tracking Child SKUs / Variants
childSku can be passed in addition to sku for better tracking and performance of other Searchspring features. If you pass only childSku, the event will be included for Personalized Recommendations, but completely ignored for Searchspring reports and other features.<script type="text/javascript" src="//cdn.searchspring.net/intellisuggest/is.min.js"></script>
<script type="text/javascript">
try{
IntelliSuggest.init({siteId:"YOUR_SITE_ID"});
IntelliSuggest.setShopperId('THE_SHOPPER_ID'); // add user id here if customer is logged in, must be after 'init' call
IntelliSuggest.haveItem({sku:"10-GRB7", qty:"3", price:"5.00"});
IntelliSuggest.haveItem({sku:"400XYZ", childSku:"400-XYZ", qty:"1", price:"10.00"});
IntelliSuggest.inSale({
orderId:"1234", // The Order ID (optional)
total:"30.00", // The total order amount (optional)
city:"Los Angeles", // Customer"s shipping address City (optional)
state:"CA", // Customer"s shipping address State (optional)
country:"US" // Customer"s shipping address 2-letter Country Code (optional)
});
} catch (e) {}
</script>
Product Clicks (Category, Brand and Search Results Pages)
These Product Click Tracking events are only relevant to those completing their own custom integration via Searchspring's RESTful API - Searchspring's AJAX-based integration will include Product Click tracking within our item templates.
If you're using the Searchspring API with the native response format, you'll need to handle search and navigation result page click tracking in your result templates.
First, you'll need to add a JavaScript function either on the page or in a JavaScript file included on that page.
function intellisuggestTrackClick(element, data, signature) {
var escapeFn = encodeURIComponent || escape;
if(document.images) {
if ('https:' == location.protocol) {
var api_url = 'https://[siteId].a.searchspring.io/api/';
} else {
var api_url = 'http://[siteId].a.searchspring.io/api/';
}
var imgTag = new Image;
imgTag.src= api_url+'track/track.json?d='+data+'&s='+signature+'&u='+escapeFn(element.href)+'&r='+escapeFn(document.referrer);
}
return true;
}
You'll then need to add the following pieces of information to onMouseDown events on your product links, add to cart buttons, etc for each product. Alternatively, you could place the event on the main product element.
onmousedown="return intellisuggestTrackClick(this, intellisuggestData, intellisuggestSignature)"
Where intellisuggestData and intellisuggestSignature are the corresponding attributes in the Searchspring API response.
Finally, in order to track the user, a COOKIE with name "_isuid" is used. If this COOKIE does not exist at the time of the result page load, then one must be generated for the current user. Any unique ID will suffice. User ID must be consistent across all IntelliSuggest events.
Comments
3 comments
On the example for the Basket Page, should the "seed" value be a list of your product SKUs, separated by spaces?
Mike,
Yes.
James
Please note: I've updated this guide to load the IntelliSuggest JavaScript (is.min.js) via the SearchSpring CDN URL. This removes the need for a document.write() that conditionally loads a version for HTTP vs HTTPS pages.
Please sign in to leave a comment.