How to track events or actions
What are events?
LeadBoxer defines an event as a signal that is send to our service . An event can represent any type of activity, but usually is something that happens on a webpage that does not trigger a page load. For example a file download, or a single page website or app.
With the LeadBoxer Lead Pixel in place, you can track (log) any action or event in your web app or website.
The Lead Pixel contains functions and listeners that facilitate the insertion of events into LeadBoxer.
Examples
basic event
<script src="//script.leadboxer.com/?dataset=YourDatasetId"></script> <script type="text/javascript"> OTLogService.sendEvent("basic event"); </script>
basic event on pageload
See the Pen Track an event by Wart Fransen (@LeadBoxer) on CodePen.
Event with properties
LeadBoxer does not only support custom events, but also adding lead properties
<script src="//script.leadboxer.com/?dataset=YourDatasetId"></script> <script type="text/javascript"> var map = new OTMap(); map.put("firstName", "John"); map.put("lastName", "Doe"); OTLogService.sendEvent("my custom event", map); </script>
Example: Track a PDF download link
To measure a click on a link that downloads a file, you can add a small piece of javascript to track this download:
<!-- Load the LeadBoxer javascript before you define the custom variable --> <script src="//script.leadboxer.com/?dataset=YourDatasetId"></script> <script type="text/javascript"> function downloadlink(file) { var map = new OTMap(); map.put("PDF", file); OTLogService.sendEvent("Download", map, false); // add 1 second delay so the event registers before downloading setTimeout(function() { window.location=file; },1000); }; </script> <p><a href="#" onclick="downloadlink('mypdf.pdf');">Download PDF</a></p> <p><input onclick="downloadlink('mypdf.pdf');" type="button" value="Download PDF" /></p>
Working example
A working example can be found here: http://api.leadboxer.com/api/examples/log/index.html
Events & Google Tag Manager
If you are using the Google Tag manager, See instructions below.
- Obviously the LeadBoxer pixel (script tag) needs to be loaded on the initial pageview.
- You need to define the page title as a variable:
function() { return document.title; }
- Create and send a new event that triggers on every Custom Event.
<script type="text/javascript"> var map = new OTMap(); map.put("lc", {{Page URL}}); OTLogService.sendEvent("{{GA PageTitle}}", map); </script>
-
Don't forget to publish and you should be set.