BlogDocumentation
Products
Identity ProtectionIdentity ManagementBlogDocumentation
Jake Whelan
Jake Whelan
27 Oct, 2023
Introduction Collecting user consents Reading and writing consents programatically Conclusion
New Feature
GDPR Compliance: Consent Management

Effortless GDPR compliance out of the box. Notify users about your intent to use cookies and request their consent.

GDPR Compliance: Consent Management

Introduction

At SlashID we make it easy for you to collect, store and process user data in a way that complies with the European Unions’ General Data Protection Regulation (GDPR) and ePrivacy Directive legislations. We deeply value your users’ privacy.

In this blog post, we’re excited to introduce the <GDPRConsentDialog> component from the SlashID React SDK. As a companion for our data residency features, the <GDPRConsentDialog> component makes GDPR compliance effortless and worry-free.

Collecting user consents

We store consents in our Data Vault, making them readily available anywhere you implement SlashID.

Consent is broken down into five high-level categories:

  1. Analytics
  2. Marketing
  3. Retargeting
  4. Tracking
  5. Necessary cookies

By default the <GDPRConsentDialog> prompts the user to Accept all or Reject all; where reject all also includes rejecting “necessary cookies”.

<GDPRConsentDialog />
The default GDPRConsentDialog state

The Customize button reveals a set of controls where a user can choose by category what consent they are comfortable to give.

Consent can be customized

Sometimes a subset of cookies are necessary to provide a service or comply with legal requirements, like data protection laws.

Enabling this is as simple as setting the necessaryCookiesRequired prop when implementing the <GDPRConsentDialog> component.

<GDPRConsentDialog necessaryCookiesRequired />
Necessary cookies can be required

We’ve built the <GDPRConsentDialog> with maximum flexibility in mind.

If you have a more complex use case like custom consent levels when choosing Accept all and Reject all, or disabling interaction with your product until consent has been given - you’re in luck! We have support for these edge-cases and more: check out the documentation.

Reading and writing consents programatically

Sometimes there are actions in your product which are gated behind a users consent, for example publishing events to your analytics platform.

With SlashID you can access a users consents with the useGDPRConsent() hook, and use it to decide whether or not the action can be performed.

import { useGDPRConsent, GDPRConsentLevel } from '@slashid/react'
import { useAnalytics } from '...'

function Component() {
  const { consents, isLoading } = useGDPRConsent()
  const { publish } = useAnalytics()

  if (isLoading) {
    return <div>Loading consent...</div>
  }

  const analyticsAllowed = consents.some(
    ({ consent_level }) => consent_level === GDPRConsentLevel.Analytics
  )

  const addToCart = () => {
    if (analyticsAllowed) {
      publish({
        name: 'add_to_cart',
        payload: {
          /* ... */
        },
      })
    }

    // ...
  }

  return <button onClick={addToCart}>Add to cart</button>
}

You might find yourself in a position where you would like to offer your users the option to “upgrade” their consent and opt-in to some functionality.

The useGDPRConsentHook() hook provides you a mechanism to do just that.

import { useGDPRConsent, GDPRConsentLevel } from '@slashid/react'
import { useAnalytics } from '...'

function Component() {
  const { consents, isLoading, updateGdprConsent } = useGDPRConsent()

  if (isLoading) {
    return <div>Loading consent...</div>
  }

  const analyticsAllowed = consents.some(
    ({ consent_level }) => consent_level === GDPRConsentLevel.Analytics
  )

  const enableAnalytics = () => {
    updateGdprConsent([
      ...consents,
      GDPRConsentLevel.Analytics
    ])
  }

  return (
    <div>
      {!analyticsAllowed && (
        <p>
          You have analytics disabled, your user dashboard has insufficient data to operate.
        </p>
        <button onClick={enableAnalytics}>
          Enable analytics
        </button>
      )}

      {/* ... */}
    </div>
  )
}

Conclusion

In this blogpost we explained how to collect user consent with the <GDPRConsentDialog> and use the data from useGDPRConsent() to make informed decisions within your product, GDPR compliance has never been easier.

Ready to try SlashID? Sign up here!

Is there a feature you’d like to see, or have you tried out SlashID and have some feedback? Let us know!

Related articles

Achieving Least Privilege: Unused Entitlement Removal

New Feature

/ 5 May, 2025

Achieving Least Privilege: Unused Entitlement Removal

Unused entitlements are one of the easiest ways for an attacker to move laterally in a target environment.

However, reducing permissions is often very difficult due to availability concerns and the complexity of the permission systems.

This blog post explores how SlashID solves this problem so that customers can automatically resize identity permissions and

achieve least privilege.

Vincenzo Iozzo
Vincenzo Iozzo
Detecting Man-in-the-Middle Attacks with SlashID

New Feature

/ 26 Aug, 2024

Detecting Man-in-the-Middle Attacks with SlashID

Detect when attackers access your website through malicious proxies with SlashID.

Ivan Kovic
Ivan Kovic
SlashID RBAC: Globally-available role-based access control

New Feature

/ 22 Jul, 2024

SlashID RBAC: Globally-available role-based access control

SlashID RBAC is a globally replicated role-based access control system that allows you to restrict access to resources based on permissions assigned to specific persons.

In this post, we will show you how to use RBAC in SlashID, and how to create permissions, and roles, and assign them to persons.

Robert Laszczak
Robert Laszczak

Ready to start a top-tier security upgrade?

Terms · Privacy · System Status
© 2025 SlashID® Inc. All Rights Reserved.

Products

Identity Protection Identity Management

Resources

Blog Get in touch

We use cookies to improve your experience. Read our cookie policy.