Privacy Plugin
Making sure that data transfer is only sent and received based on your visitor's consent.
The Privacy Plugin allows you to granularly control what Ninetailed SDK events can trigger and what properties those events can contain with and without your visitors' consent.
The values you pass as configuration when instantiating the plugin determine what events and properties can be sent before or without your user's consent. The plugin provides a
consent
method than when called then allows all Ninetailed SDK events to be triggered with any properties.Add
@ninetailed/experience.js-plugin-preview
as a dependency:npm
yarn
npm install @ninetailed/experience.js-plugin-privacy
yarn add @ninetailed/experience.js-plugin-privacy
Add plugin to the
plugins
prop of the NinetailedProvider
:React
Next.js
Gatsby
In React, add the plugin to Ninetailed Provider:
<NinetailedProvider
// ...
plugins={[
new NinetailedPrivacyPlugin()
]}
clientId={PUBLIC_NINETAILED_CLIENT_ID ?? ""}
environment={PUBLIC_NINETAILED_ENVIRONMENT ?? "main"}
>
<Component {...pageProps} />
</NinetailedProvider>;
In Next.js, add the plugin to Ninetailed Provider:
<NinetailedProvider
// ...
plugins={[
new NinetailedPrivacyPlugin()
]}
clientId={PUBLIC_NINETAILED_CLIENT_ID ?? ""}
environment={PUBLIC_NINETAILED_ENVIRONMENT ?? "main"}
>
<Component {...pageProps} />
</NinetailedProvider>;
In Gatsby, add the plugin to the plugins array:
plugins: [
// ...
{
resolve: `@ninetailed/experience.js-gatsby`,
options: {
clientId: PUBLIC_NINETAILED_CLIENT_ID,
environment: PUBLIC_NINETAILED_ENVIRONMENT,
ninetailedPlugins: [
{
resolve: `@ninetailed/experience.js-plugin-privacy`,
options: {}
}
]
}
}
]
Use these properties in the configuration object passed when instantiating the plugin. Passing a blank configuration object will use the default values.
Property Name | Description | Default | Available |
---|---|---|---|
allowedEvents | Which events you want to allow? | ['page', 'track'] | An array containing any of page , track , identify |
allowedPageEventProperties | Which page event properties will be allowed? | [*] | An array of your page event properties as strings or use [*] |
allowedTrackEvents | What .track event names will be allowed? | [] | An array of your track event names as strings or use or use [*] |
allowedTrackEventProperties | What .track event properties (additional data on a track event) will be allowed? | [] | An array of your track event properties as strings or use or use [*] |
allowedTraits | What user traits will be allowed? | [] | An array of your .identify event traits or use or use [*] |
blockProfileMerging | Shall the merging of profiles (attaching an ID to a profile via identify ) be allowed? | true | true or false |
enabledFeatures | What additional features should be enabled? | [] | An array of strings corresponding to feature names to enable. Possible values are:
|
If you are using the default use, default values based on the table above will be used.
React
Next
Gatsby
<NinetailedProvider
// ...
plugins={[
new NinetailedPrivacyPlugin()
]}
>
// ...
</NinetailedProvider>
<NinetailedProvider
// ...
plugins={[
new NinetailedPrivacyPlugin()
]}
>
// ...
</NinetailedProvider>
This configuration demonstrates overriding the default configuration to allow
identify
events to be sent and for those identify
event calls to capture the firstName
trait before or without user consent. All unspecified config object options use their default values.React
Next
Gatsby
<NinetailedProvider
// ...
plugins={[
new NinetailedPrivacyPlugin({
allowedEvents: ['page', 'track', 'identify'],
allowedTraits: ['firstName'],
}),
]}
>
// ...
</NinetailedProvider>
<NinetailedProvider
// ...
plugins={[
new NinetailedPrivacyPlugin({
allowedEvents: ['page', 'track', 'identify'],
allowedTraits: ['firstName'],
}),
]}
>
// ...
</NinetailedProvider>
The plugin attaches a
consent
method to the window.ninetailed
object. The consent method takes a single boolean argument. When the argument is true
, this sets a localStorage entry of __nt-consent__: "accepted"
. When not called or the argument is set to false
, the __nt-consent__
local storage entry is cleared. Call this method in your client-side application when a user has taken an action that indicates their explicit consent.window.ninetailed.consent(true) // sets `__nt-consent__: "accepted" in local storage
window.ninetailed.consent(false) // clears `__nt-consent__` from local storage
Last modified 1mo ago