Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
gb-tracker-client
Advanced tools
This is the JavaScript SDK used to send beacons to GroupBy. It can only run in the browser. A bundled UMD build is available from our CDN (see GroupBy docs for CDN link) and a CommonJS build is available for linking into NPM build processes with a bundler. E.g. React, Angular.
Add the CDN <script>
to each page, above where the tracker is instantiated and used:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="http://cdn.groupbycloud.com/gb-tracker-client-<major_version>.min.js"></script>
<script>
var tracker = new GbTracker('customer_id', 'area');
tracker.autoSetVisitor();
tracker.sendAddToCartEvent({ ... });
</script>
</head>
<body>
</body>
</html>
To import and use the tracker:
import GbTracker from 'gb-tracker-client';
const tracker = new GbTracker('customer_id', 'area');
tracker.autoSetVisitor();
tracker.sendAddToCartEvent({ ... });
If you're using TypeScript, you can also use the types for each event type. Each function has a corresponding TypeScript type that can be imported:
import GbTracker from 'gb-tracker-client';
import { AddToCartEvent } from 'gb-tracker-client/models';
const tracker = new GbTracker('customer_id', 'area');
tracker.autoSetVisitor();
const a: AddToCartEvent = { ... };
tracker.sendAddToCartEvent(a);
The constructor for the tracker client has a third, optional parameter for providing options:
const tracker = new GbTracker('customer_id', 'area', {
overrideUrl: '<some_url>' // Optional, overrides the URL the beacon is sent to. Useful for testing.
});
List of supported event types with code examples available in event-types.md file
This new functionality allows you to indicate which specific site or banner the tracker is running in.
const tracker = new GbTracker('customer_id', 'area');
tracker.setSite('siteName');
The setSite
function will apply the given site to all beacons fired after that point.
Whenever a Search
, Home page view
, View product
, Add to cart
, Order
, or Impression
beacon is fired, the site value, if it exists, will be added as part of the metadata in the request.
The first party cookie gbi_visitorId
is set with an empiry time of 1 year that is extended each time the shopper visits again. This is used to anonymously track the shopper.
IMPORTANT
As of version 5.0.0, the way shopper tracking works has changed and includes cross-domain support. Shoppers will be tracked across your domains if cross-domain rules are met (see next section). Tracking on domains whose apex domain has a two-level suffix is supported from version 5.1.2. Examples:
.com
- You can use version 5.0.0 or higher..co.uk
- You can use version 5.1.2 or higher.For shoppers to be tracked across your domains, the domains must share the same apex domain. Examples:
a.example.com
and b.example.com
a.example.com
and example.com
example.com
and a.example.com
Starting with version 5.1.2, many two-level domain suffixes such as .co.uk
are also supported.
If your domain has a multi-level suffix that is not in the list of supported domain suffixes, please contact support@groupbyinc.com for assistance.
If you upgrade from 3 or 4 to 5, the visitor ID values generated by version 3 or 4 of the tracker client will be re-used. Whichever domain the shopper visits next once you start using version 5, the visitor ID generated for that domain will be re-used as the visitor ID for the apex domain, thereafter shared between each of your domains.
For example, if a shopper performed the following events, the visitor ID abc
would be re-used:
www.example.com
, at which point version 3 or 4 sets the visitor ID to abc
.checkout.example.com
), at which point version 3 or 4 sets the visitor ID to bcd
.bcd
with abc
), and completes the purchase.See the docs for more detailed information about implementing beacons:
https://docs.groupbycloud.com/gb-docs/gb-implementation/beacons/overview
FAQs
GroupBy client-side event tracker
The npm package gb-tracker-client receives a total of 1,053 weekly downloads. As such, gb-tracker-client popularity was classified as popular.
We found that gb-tracker-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 22 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.