Tracking Events
After adding the Tracklution script to your website, you can start tracking events.
Make sure the main script is always loaded before any event scripts! Otherwise the event scripts won't work and Tracklution will not register events.
You will need to add the code to the relevant pages on your website.
For example, if you want to track a purchase event, you will need to add the code for the Purchase event to the purchase confirmation page on your website which will trigger the "Purchase" event.
Event Types
Standard Events
Event Type |
---|
PageView |
ViewContent |
AddToCart |
CompleteRegistration |
StartTrial |
Subscribe |
InitiateCheckout |
Lead |
Purchase |
ContactInfo |
Custom Events
On top of the above mentioned Standard Events, you can use any Custom scrips also. Just change the event name in the script to match the event name you prefer using and install the script in the desired location or action on the site.
<script>
lsq('track', 'YourCustomEventNameHere');
</script>
Event mappings towards Connectors can be handled in Tracklution UI. Read more about event mappings
Event Code examples
The code will call the lsq-function in the Tracklution Pixel script and you will need to pass:
- "track" as the first parameter
- the event type as the second parameter
- based on the event type, you will need to pass the event data as the third parameter
For example, if you want to track a PageView event, you will need to add the following code to the page you want to track:
<script>
lsq('track', 'PageView');
</script>
These code snippets need to go in the <body>
tag of your website.
Purchase Event
The Purchase event is used to track a purchase on your website. The "Purchase" event also needs a third parameter which is an object containing the purchase data.
The values for "value" and "currency" here are just examples and for demonstration purposes. You will need to pass the correct, actual values for your purchase to these fields on your website's code.
<script>
lsq('track', 'Purchase', {value: 2.25, currency: 'EUR'});
</script>
Partial Purchases or Virtual Purchases
This is useful if you wish to track virtual purchases or your business model includes multiple purchases happening within one session.
Tracklution will gather all partial purchases and calculate them together, and pass them on to Connectors as a single Purchase.
Partial Purchases collected within a session can be overwritten with an actual Purchase (Purchase that does not include ´isPartial´ setting).
Use case example 1:
You want to provide additional Purchase signals to Ad platforms of users that have shown valuable actions in the site but who do not finalise actual purchase.
This could be for example a user that spent a lot of time in the site and gathered products to shopping cart, but never finalised the purchase. Another good example is to set a Partial Purchase for a customer that subscribes to Newsletter, because you can later reach and convert the user via direct marketing.
We would like to tell to Ad platform that this was still a fairly good visitor (compared to visitors who do not perform any valuable actions).
We can set a Purchase event with partial Purchase that captures e.g. 5% of the shopping cart value:
<script>
lsq('track', 'Purchase', {value: 5%ofShoppingCartValueHere, currency: 'EUR', isPartial: true});
</script>
Tracklution gathers this partial Purchase information and waits if actual final Purchase happens.
- If there is no final Purchase, Tracklution will send this partial Purchase to ad platform to provide additional signals of engaged users.
- If the final, real Purchase happen, this partial Purchase is overwritten and the actual Purchase with actual value is sent forward and partial Purchase is ignored.
Use case example 2:
Users are making multiple purchases within one session. Tracklution can gather all these purchases and send forward to Connectors as one Purchase (some Ad Platforms only receive one Purchase per session, so in case of multiple Purchases, part of the Purchase value would be lost).
Fire this tag always when partial Purchase happens:
<script>
lsq('track', 'Purchase', {value: PartialPurchaseValueHere, currency: 'EUR', isPartial: true});
</script>
Tracklution will gather all partial Purchases within the session, calculate them together, and send forward as one Purchase event to Connectors.
ContactInfo event
ContactInfo event
The ContactInfo event has these parameters:
- "set"
- "ContactInfo" (the type of event)
- an object containing the contact information (email, phoneNumber, firstName, lastName)
To send a ContactInfo type event to Tracklution, you need to add the following code to your website's HTML code on the pages you have contact information available on:
You need to set the appropriate values to your ContactInfo event! The values here are just placeholders for demonstration purposes.
<script>
lsq('set', 'ContactInfo', {
email: 'example@email.com',
phoneNumber: '+358501234567',
firstName: 'David',
lastName:'Smith',
birthday: '1985-06-17'
gender: 'male',
address: 'Street 1',
postCode: '11015',
city: 'Berlin',
country:'Germany',
externalId: '123-91197003219'
});
</script>
This example below includes all parameters that can be passed with ContactInfo tag. You can freely choose which parameters to implement, just remove the ones from the script you wish not to implement.
Data hashing for ContactInfo
Tracklution will naturally take care of hashing the data (SHA256 decryption) before data is forwarded to any Connectors.
If you wish to hash data before sending it to Tracklution, hashed data can be implemented into the script exactly the same way you would implement non-hashed data, for example instead of ´email: 'example@email.com'´ you can insert hashed value: ´email: 'hashedValueHere'´.