Installing Beacon Tracker
Adding Beacon Events
Testing Beacons
Verify Beacons Sent
Verify Beacons Health
Installing Beacon Tracker
Follow the below steps to install the GroupBy tracker to your website:
- Add tracker script
- Instantiate the GbTracker
- Verify tracker installation
Step 1: Add Tracker
NPM | CDN |
---|---|
Apps that use a bundler like Webpack can import the tracker from NPM.npm install gb-tracker-client |
Add the Beacons Tracker JavaScript to each of your website’s HTML pages.<script src="http://cdn.groupbycloud.com/gb-tracker-client-3.min.js"></script> |
Step 2: Instantiate GbTracker
NPM | CDN |
---|---|
import GbTracker from 'gb-tracker-client'; // call autoSetVisitor before using the tracker instance const gbTracker = new GbTracker('CustomerID', 'Area'); gbTracker.autoSetVisitor('loginID'); |
Place this code below the Event Tracker JavaScript added in Step 1.// call autoSetVisitor before using the tracker instance var gbTracker = new GbTracker('CustomerID', 'Area'); gbTracker.autoSetVisitor('loginID'); |
Parameter | Type | Required? | Description |
---|---|---|---|
CustomerID | String | Yes | Your GroupBy Customer ID. |
Area | String | Yes | GroupBy area such as Production, Staging, Demo, and so on. |
Call the autoSetVisitor
to configure the Visitor ID and Session ID cookies before using the tracker instance.
-
If the values for the Visitor ID and Session ID cookies are already set, the tracker instance uses them while sending the beacon. The cookies reset to the existing values but with new expiry dates.
-
If values for the cookies do not exist, new values are generated and set with expiry dates. When set, the Visitor ID cookie expires in 10 years and the Session ID cookie expires after 30 minutes of shopper inactivity.
autoSetVisitor
has an optional parameter for the LoginID.
Parameter | Type | Required? | Description |
---|---|---|---|
LoginID | String | No | Hashed client information as stored in your database. |
Including the shopper’s username helps GroupBy track the shopper’s journey across devices. Hash this value before setting it in the tracker to comply with data privacy laws.
Step 3: Verify tracker installation
To verify that the tracker is successfully installed, navigate to your browser’s developer tools.
-
Chrome: Press CTRL + SHIFT + J while viewing the page to debug
-
Firefox: Press CTRL + SHIFT + K while viewing the page to debug
-
Microsoft Edge: Press F12 while viewing the page to debug
Look for the GbTracker constructor in the developer console. To quickly locate the constructor, start typing gbtracker in the console prompt.
If you see nothing helping you autocomplete the tracker’s constructor name, it wasn’t installed correctly.
If you see the name gbtracker autocompleted for you, it was installed correctly.