Follow

9.2 Dokumentation: Heycommerce produkt tracking

Documentation and tracking script for HLBI

DISCLAIMER:
It’s your responsibility to implement the tracking script. Heyloyalty cannot be held accountable to any unique setup you may have on your website..

Note: When using the free-version of our abandoned_basket, you are restricted to just the abandoned_basket trigger and your data will only be saved for 7 days.

 

You have 2 options for sending data to your heycommerce database:

 

  1. Implementing the tracking using javascript
  2. Using our API to send information

 

NB! To use HeyCommerce (and avoid getting 400 error respons), make sure your account has activated to the HeyCommerce feature.


To activate the feature go to “Listeintegrationer” on your Heyloyalty account. Activate the following integration: Heycommerce

 

Integration_setup.png

Remember to set it up, using a productfeed that matches the productID’s send using the tracking script mentioned further down.

 

 

Implementing the Script

When using Heycommerce, it’s possible to have multiple lists responding to a single domain.

At the same time, it’s possible to have the tracking work on a single list. The latter is done by adding the trackingID as a third value in the script.

 

 

Using generic tracking script:

The tracking script looks like this:

 

<script type="text/javascript" language="javascript">
var hlt;
var BiTrackingLoaded = function (BiTracking) {
hlt=BiTracking;
BiTracking.initialize('INSERTAPIKEYHERE', INSERTSESSIONTIMEHERE, INSERTTRACKINGID);
}
</script>
<script>
(function (d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
h = "https:" == document.location.protocol ? "https://" : "http://";
g.src = h + 'bi.heyloyalty.com/hlbi.js';
s.parentNode.insertBefore(g, s);
}
(document, 'script'));
</script>

 

 

INSERTAPIKEYHERE = is your Heyloyalty API key. You can find this under “Kontooplysninger” on your Heyloyalty account.

INSERTSESSIONTIMEHERE = Define how long a session lasts. Insert the number of minutes, the session needs to be before an event is triggered.

INSERTTRACKINGID = is your Heyloyalty Tracking Id and it’s optional.
It will ensure tracking only applies to a single list.
You can apply it, if your account needs different trackingscripts to run on multiple lists.

 

NB! You can find your Tracking Id when you open Heycommerce, found in “Listeintegration”.

 

Finding_integrationId.png

 

 

 

Events

To track events, you need to fire specific events from the site. The events must be placed somewhere within your javascript, anywhere from your site, whenever a specific page is loaded.

Make sure to only fire the event, from the correct corresponding page

 

hlt.visit(PRODUCTID, CATEGORYID, CATEGORYNAME); 
All subpages, containing produktinfo. This could be a specific produktpage or a category page.

On product pages you should send the PRODUCTID (productid is - among other things – used for product interest). If possible, send the CATEGORYID and CATEGORYNAME aswell (as a minimum, we need the categoryname to trigger category interest events).

On a category page, sending a category allows you to use category interest triggers at a higher rate.

 

hlt.addToBasket(PRODUCTID, PRODUCT COUNT, CATEGORYID, BASKETID, CATEGORYNAME); 
This event can be fired from either the Basketpage or every add-to-basket button. Both need to include purchase info.

If you add it to the basketpage, you need to fire the event for each product added to the basket.

 

hlt.removeFromBasket(PRODUCTID); 
This event should be fired whenever a product is removed from the basket. It will update our end, notifying us that the product has been removed and should be added in case of an add-to-basket email.

 

hlt.purchasedBasket(); 
This event is to be fired from the Basket-thank-you page after the customer completes their purchase.The event takes no parameter

 

hlt.pairEmail(EMAIL); 
For pairing directly from a sign-up/sign-in form. This event is optional, if you don’t want to pair the email from sign-up forms.

We utilize a “pair-on-click” from every email/sms/heypush send from Heyloyalty. Whenever a customer clicks and is directed to your site, the pairEmail event will fire automatically

 

hlt.heartbeat(); 
For visit to pages without a specific product.
This event should should only be used to notify that the session is still alive. No tracking will be collected for triggering or segmentation.

 

 

Remember to place the data-events within a script-tag.

example:

<script>….

 

hlt.visit(945, 2);

….

</script>

 

 

Example - with visit event

 

<script type="text/javascript" language="javascript">
var hlt;
var BiTrackingLoaded = function (BiTracking) {
hlt=BiTracking;
BiTracking.initialize('INSERTAPIKEYHERE', INSERTSESSIONTIMEHERE);
hlt.visit(“PRODUCTID”,”CATEGORYID”) }
</script>
<script>
(function (d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
h = "https:" == document.location.protocol ? "https://" : "http://";
g.src = h + 'tracking.heycommerce.dk/hlbi.js';
s.parentNode.insertBefore(g, s);
}
(document, 'script'));
</script>

 

 

Example - visit event
When using the visit event, the values a mandatory. 
Example with only categoryName ('thisCategory'):
hlt.visit('', '', 'thisCategory'); 
This could be used for search results or category pages.

 

addToBasket event

when using addToBasket, ProductId and amount (number of products put into the basket) is required.
Example with CATEGORYNAME and no CATEGORYID, BASKETID:
hlt.addToBasket('myId', 1, '', '', 'thisCategory'); 

 

 

Alternatively, you can use:

hlt.syncInfo(TYPE, DATA)

Where type is in: addtobasket, removefrombasket, visit, pairEmail, purchasebasket and Data is a url encoded parameters examples:

 

hlt.syncInfo('addtobasket', '&productId=1&amount=2&categoryId=3');

hlt.syncInfo('removefrombasket', '&productId=1');

hlt.syncInfo('visit', '&productId=1&categoryId=3');

hlt.syncInfo('pairEmail', '&email=test@test.dk');

hlt.syncInfo('purchasebasket', '');

 

 

Example

 

<script type="text/javascript" language="javascript">
var hlt;
var BiTrackingLoaded = function (BiTracking) {
hlt=BiTracking;
BiTracking.initialize('INSERTAPIKEYHERE', INSERTSESSIONTIMEHERE);
hlt.syncInfo('addtobasket', '&productId=1&amount=2&categoryId=3')}
</script>
<script>
(function (d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
h = "https:" == document.location.protocol ? "https://" : "http://";
g.src = h + 'tracking.heycommerce.dk/hlbi.js';
s.parentNode.insertBefore(g, s);
}
(document, 'script'));
</script>

 

 

When can you trigger emails from Heyloyalty? 

The below options show the possible days from where you'll be able to trigger emails from Heyloyalty, using HLBI

//Last number for last_visit and purchase are the days since last visit / purchase

last_visit_7
last_visit_14
last_visit_30
last_visit_60
last_visit_90
last_purchase_7
last_purchase_14
last_purchase_30
last_purchase_60
last_purchase_90

 

//First number is the number of days we look at. The second parameter are the number of visits to a specific product in the period

product_interest_7_2
product_interest_7_3
product_interest_7_4
product_interest_7_5
product_interest_7_6
product_interest_7_7

 

 

 

 

 

Documentation Generic tracking through API:

 

 

Required:
All requests require the following parameters:
session
cookie
Optional: integrationID

 

Track product visits:
route is /visit/{apikey} (apikey is your Heyloyalty API key).
Requires following parameters:
session, cookie, productId, categoryId, categoryName, url

Example:

https://tracking.heycommerce.dk/visit/myApiKey
?cookie=b0919c4c-a4a6-44d8-b72b-7d0d4f9ec9ba
&session=61931939-8945-42e7-9929-21fd2aaaa1b9
&productId=202427
&categoryId=1
&categoryName=name
&url=https://www.heyloyalty.com/

 

Track product added to basket:
route is /addtobasket/{apikey} (apikey is your Heyloyalty API key).
Requires following parameters:
session, cookie, productId, amount, categoryId, categoryName, url, basketId

Example:

https://tracking.heycommerce.dk/addtobasket/myApiKey
?cookie=b0919c4c-a4a6-44d8-b72b-7d0d4f9ec9ba
&session=61931939-8945-42e7-9929-21fd2aaaa1b9
&productId=202427
&amount=1
&categoryId=1
&url=https://www.heyloyalty.com/
&categoryName=name
&basketId=myBasketId

 

Track product removed from basket:
route is /removefrombasket/{apikey} (apikey is your Heyloyalty API key).
Requires following parameters:
session, cookie, productId.

Example:

https://tracking.heycommerce.dk/removefrombasket/myApiKey
?cookie=b0919c4c-a4a6-44d8-b72b-7d0d4f9ec9ba
&session=61931939-8945-42e7-9929-21fd2aaaa1b9
&productId=202427

 

Track that session have been bought:
route is /purchasebasket/{apikey} (apikey is your Heyloyalty API key).
Requires following parameters:
session, cookie.

Example:

https://tracking.heycommerce.dk/purchasebasket/myApiKey
?cookie=b0919c4c-a4a6-44d8-b72b-7d0d4f9ec9ba
&session=61931939-8945-42e7-9929-21fd2aaaa1b9

 

Pair cookie with email:
route is /pairemail/{apikey} (apikey is your Heyloyalty API key).
Requires following parameters:
session, cookie, email.

Example:

https://tracking.heycommerce.dk/pairemail/myApiKey
?cookie=b0919c4c-a4a6-44d8-b72b-7d0d4f9ec9ba
&session=61931939-8945-42e7-9929-21fd2aaaa1b9
&email=minEmail


Adding IntegrationID
If you have several list and want your tracking only relates to a single specific list, you can use the integrationID for that specific list:
If you wish to use your integrationId, the route takes that as a parameter:

?integrationId=myIntegrationID


the rest of the parameters are then added:

Example:
https://tracking.heycommerce.dk/visit/myApiKey
?integrationId=myIntegrationID
&cookie=b0919c4c-a4a6-44d8-b72b-7d0d4f9ec9ba
&session=61931939-8945-42e7-9929-21fd2aaaa1b9
&productId=202427
&categoryId=1
&categoryName=name
&url=https://www.heyloyalty.com/

 

 

 

Sync old orders:

route is /createorder/{apikey}
Structure is a json object of the following format:

{
  "email": "test@test.com",
  "created_at": "2017-04-04 04:04:04",
  "products": [{
    "product_id": "1",
    "variation_id": "2",
    "amount": 1
    },
    {
    "product_id": "3",
    "variation_id": "2",
    "amount": 1
    }]
}

Note that variation_id is optional.

  

Cross Domain tracking

Its possible to parse cookies and sessions from different domains that is done by parsing hccookie and hcsession parameters in the URL. These can be fetched from the current tracking by calling hlt.cookieId and hlt.sessionId

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk