Your situation
Grain Tag or Analytics Web
The script tag and the npm package are the same Grain Tag code. The script tag is an IIFE build
with the tenant alias injected. Read Authentication for the strategies.
Install Grain Tag with a script tag
Add one tag to the HTML of every page:GrainTag.track sends a custom event, and GrainTag.identify sets
the user ID after a login:
Install Grain Tag with npm
For an app with a build step, install@grainql/tag:
init one time. track and identify are safe to call before init completes. The
package queues the calls and replays them:
Install Analytics Web
For a server, or for React hooks and remote configuration, install@grainql/analytics-web:
The tenant alias
Every install uses the tenant alias, not the tenant UUID. The alias is the human-readable identifier that the dashboard shows athttps://grainql.com/dashboard. Replace your-tenant-id
with it in every example on this site.
Consent
Grain Tag is cookieless by default. ItsconsentMode has three values:
consent.grant() moves the visitor to a persistent ID in localStorage, not in a cookie.
consent.revoke() clears the stored ID and returns to daily rotating IDs. Read
Privacy and consent.
Platform support
Make sure that Grain receives events
For a script tag install:- Open the browser console on a page that loads the script. Grain Tag writes its initialization logs there.
- Run
GrainTag.track('installation_test')in the console. - Open the dashboard at
https://grainql.com/dashboard. The event shows within 30 seconds.
debug: true and send one event: