- Track transitions/virtual page views in single-page apps.
- Track non-page view events, such as in-page dialogs or video/media playback.
The Leadfeeder tracker script exposes a set of methods for the web page to call if needed. All these methods exist under the window.ldfdr -object in the page.
Sends a page view event. It supports arguments as an object.
pageTitle: "Example page"
If the arguments are not present, it will default to window.location.href for pageUrl and document.title for pageTitle.
For SPA tracking, calling window.ldfdr.pageview()without arguments after a state change is usually enough as new pageUrl and pageTitle will be automatically picked up.
Returns an array of all tracker instances on the page. See getTracker() below for details on how to interact with the tracker instances.
Get a tracker instance by trackerId. For the tracker instance following methods are supported:
var tracker = window.ldfdr.getTracker("abcdef");
// Sends a pageview to specific tracker, supports
//same arguments as pageview() above
You can obtain the Leadfeeder clientId with the following call:
ClientID is the visitor ID that is stored in the Leadfeeder cookie. It matches to the lf_client_id field that is returned from the Leadfeeder API's visits end-point.
Sample use case: SPA tracking with Google Tag Manager
STEP 1: Add a new Custom HTML tag in your Google Tag Manager.
STEP 2: Name as appropriate.
STEP 3: Add the following code to HTML section:
STEP 4: Configure a trigger for "History change".
STEP 5: Test in Google Tag Manager’s Debug mode.