Skip to content

Checker Script

The AgeVerif Checker Script is a client-side JavaScript script pasted on your WEBSITE that blurs all content and displays a fullscreen modal, forcing the VISITOR to prove they are an adult before accessing the WEBSITE.

Checker Start

To display the Checker, you can either:

Requirements

You MUST be registered on our Webmasters Platform as a WEBMASTER, available at https://webmasters.ageverif.com.

You MUST have a WEBSITE registered on the platform: https://webmasters.ageverif.com/website/add.

You SHOULD be familiar with HTML. To install the Checker you need to edit some code.

Normal Flow

  1. A new VISITOR enters your WEBSITE.

  2. All content is immediately blurred and a fullscreen modal is displayed.

  3. The VISITOR goes through the verification process, guaranteeing they are an adult.

  4. The Checker closes and your WEBSITE is now visible, unblurred.

Session Duration

The VISITOR is verified for the next 60 minutes. After this period, per French regulation, the VISITOR must verify their age or login again.

Data Privacy

No data is shared between WEBSITEs. The VISITOR must verify their age on each WEBSITE they access.

Automatic Integration

The easiest way to integrate the Checker is by pasting a one-line <script> on your WEBSITE's HTML code.

Don't worry about blurring the content

With this integration the Checker starts immediately when the VISITOR accesses your WEBSITE.

All content will be blurred until the VISITOR proves they are an adult.

  1. Go to the Webmasters Platform, selected your WEBSITE and click on "Edit Website Settings".

  2. Copy your WEBSITE's 🟢 Public Live Key.

  3. Copy the script below and replace [KEY] with the Public Live Key.

    html
    <script src="https://www.ageverif.com/checker.js?key=[KEY]"></script>
  4. Paste it on your WEBSITE's HTML code, preferably right before the closing </head> tag.

    html
    <!DOCTYPE html>
    <html lang="en">
        <head>
        ...
        <!-- Load AgeVerif Checker -->
        <script src="https://www.ageverif.com/checker.js?key=[KEY]"></script>
        </head>
        <body>...</body>
    </html>
  5. That's it! AgeVerif's Checker Script is now integrated on your WEBSITE.

Development and testing

If you are integrating the Checker on your local machine, you SHOULD use the 🟡 Public Test Key:

html
<script src="https://www.ageverif.com/checker.js?key=[TEST_KEY]"></script>

This will bypass domain checks and enable debug logs.

Advanced Integration

If you want more control over how and when the Checker is displayed, you can stop it from automatically starting and use the JavaScript API to manipulate it.

  1. Go to the Webmasters Platform, selected your WEBSITE and click on "Edit Website Settings".

  2. Copy your WEBSITE's 🟢 Public Live Key.

  3. Copy the script below, replace [KEY] with the Public Live Key and add the nostart parameter.

    html
    <script src="https://www.ageverif.com/checker.js?key=[KEY]&nostart" async defer></script>

    Optional Attributes

    The async and defer attributes are optional, but recommended to avoid blocking the page load.

  4. Paste it on your WEBSITE's HTML code, but this time right before the closing </body> tag.

    html
    <!DOCTYPE html>
    <html lang="en">
        <head>...</head>
        <body>
        ...
        <!-- Load AgeVerif Checker -->
        <script src="https://www.ageverif.com/checker.js?key=[KEY]&nostart" async defer></script>
        </body>
    </html>
  5. Check the JavaScript API to start the Checker manually and to listen to events.

    Don't forget to start the Checker!

    When using the nostart parameter, you need to manually start the Checker by calling ageverif.start().

Script query parameters for checker.js

The checker.js script can be customized by adding query parameters to the URL.

html
<script src="https://www.ageverif.com/checker.js?key=ExampleKey&nostart&language=en&onload=ageverifLoaded&onready=ageverifReady&onsuccess=ageverifSuccess&onerror=handleError" async defer></script>
FieldTypeFormatDescription
keystring(40)E.g. DtD0ad9ZMcKJBd9Ojh8D8Q0ELh2eSKwb0f1SzN7EYour WEBSITE's Key, found in the Webmasters Platform
nostartnone (optional)(empty)Prevents the Checker from starting automatically.
Use ageverif.start() JavaScript function
languagestring (optional)E.g. en
Default: auto
Forces a given language.
Available: auto,en,fr,es,pt,it,de.
Auto is based on the VISITOR's browser language
onloadstring (optional)E.g. ageverifLoadedCalls the given function when the script is loaded.
window.ageverif is available after this event
onreadystring (optional)E.g. ageverifReadyCalls the given function when the Checker is visible to the VISITOR and ready to start the verification process
onsuccessstring (optional)E.g. ageverifSuccessCalls the given function when the VISITOR has been successfully verified or when no verification is required
onerrorstring (optional)E.g. handleErrorCalls the given function when a fatal error occurs and the Checker is not able to initialize or proceed

Functions must be defined in the global scope

Functions passed to the checker.js script as query parameters must be defined in the global scope window before the script is loaded.

E.g. window.ageverifLoaded = () => ...; must be defined before the <script> is loaded.

Common Issues

Always check the console for errors

Most issues will appear on your browser's console

The Checker is not being displayed

  • Make sure you are using the correct Key for your WEBSITE.

    A Public Live Key can only be used on the configured domain and subdomains. Use the Public Test Key for local development.

  • Make sure the Checker script is being loaded correctly on the HTML.
  • Make sure the Checker is not blocked by an adblocker, browser extension or Content Security Policy (CSP).
  • If the VISITOR is already verified for the current session, the Checker is not displayed.

    The success event will be triggered, but the ready event will not.

  • The VISITOR may be on a region where age verification is not required.

JavaScript API

Control the Checker through the JavaScript API, available on the global ageverif object or window.ageverif.

ts
interface AgeVerif {
  requiresVerification: boolean;
  verified: boolean;

  start(forceVerification?: boolean): Promise<void>;
  clear(): void;
  destroy(): void;
  on(event: string, listener: Function): () => void;
  off(event: string, listener: Function): void;
}

Properties

requiresVerification

js
requiresVerification: boolean

Whether the VISITOR must pass the verification process on the current region to access the WEBSITE:

ValueDescription
trueVISITOR is on a region where age verification is required.
(Still true even if the VISITOR is already verified)
falseVISITOR is on a region where age verification is not required

How do I set the regions?

Countries/regions are set by the WEBMASTER on the Webmasters Platform.

verified

js
verified: boolean

Verification status of the current VISITOR:

ValueDescription
trueVISITOR has been successfully verified and the session is still valid
trueNo verification is required (requiresVerification = false)
falseVISITOR has not been verified and must pass the verification process

Methods

start()

js
async start ( forceVerification = false ): Promise<void>

Starts the Checker.

Parameters

FieldTypeFormatDescription
forceVerificationboolean (optional)E.g. true. Default: falseForce verification to start even if the VISITOR is currently verified

Returns

A promise that resolves when the VISITOR has been successfully verified.

What if the VISITOR is already verified?

If the VISITOR is verified when calling start(), the Checker will not open and the promise will resolve immediately.

The 'success' event will be triggered, but the 'ready' event will not.

clear()

js
clear (): void

Clears/Resets the VISITOR verification status.

destroy()

js
destroy (): void

Destroys the Checker and removes it from the DOM.

on()

js
on ( event: string, listener: Function ): () => void

Registers a Listener for a given event.

Check the Events section for all available events.

Parameters

FieldTypeFormatDescription
eventstringE.g. successEvent name to listen for
listenerFunctionE.g. () => ...Function to be called when the event is triggered

Returns

A function that removes the listener from the event listeners

off()

js
off ( event: string, listener: Function ): void

Removes a Listener for a given event

Parameters

FieldTypeFormatDescription
eventstringE.g. successEvent name to remove the listener from
listenerFunctionE.g. () => ...Function to be removed from the event listeners

Events

Overview:

ts
type EventName = 'load' | 'ready' | 'success' | 'error';

You can bind a listener to most events in 3 different ways:

  • Using the ageverif.on() method

    js
    ageverif.on('success', () => ...);
  • Using the window.addEventListener() method, with the event name prefixed by "ageverif:"

    js
    window.addEventListener('ageverif:success', () => ...);
  • Defining a function in the global scope window and passing it as a query parameter to the script (Check Script query parameters)

    html
    <script>window.ageverifSuccess = () => ...;</script>
    <script src="https://www.ageverif.com/checker.js?key=[KEY]&onsuccess=ageverifSuccess" async defer></script>

'load'

Triggered when the Checker script is loaded and the ageverif object becomes available.

The first parameter is an object containing:

  • verified (boolean) - Current VISITOR verification status
js
window.addEventListener('ageverif:load', (event) => ...); // Verified status = event.detail.verified
window.ageverifLoaded = ({ verified }) => ...; // Add script query parameter ?onload=ageverifLoaded

Some bindings are not available

ageverif.on('load', ...) binding does not exist for this event as the ageverif object is will not be available at that time.

'ready'

Triggered when the Checker is visible to the VISITOR and ready to start the verification process.

js
ageverif.on('ready', () => ...);
window.addEventListener('ageverif:ready', () => ...);
window.ageverifReady = () => ...; // Add script query parameter ?onready=ageverifReady

'success'

Triggered when the VISITOR has been verified and the Checker is closed.

Also triggers when the VISITOR is already verified, after calling ageverif.start().

js
ageverif.on('success', () => ...);
window.addEventListener('ageverif:success', () => ...);
window.ageverifSuccess = () => ...; // Add script query parameter ?onsuccess=ageverifSuccess

'error'

Triggered when a fatal error occurs and the Checker is not able to initialize or proceed.

The first parameter contains the error object.

js
ageverif.on('error', (error) => ...);
window.addEventListener('ageverif:error', (event) => ...); // Error = event.detail.error
window.handleError = (error) => ...; // Add script query parameter ?onerror=handleError

Examples

One-line Automatic Integration

This method starts the Checker immediately when the VISITOR accesses your WEBSITE.

All content is automatically blurred until the VISITOR proves they are an adult.

html
<!DOCTYPE html>
<html lang="en">
  <head>
    ...
    <!-- Load AgeVerif Checker -->
    <script src="https://www.ageverif.com/checker.js?key=[KEY]"></script>
  </head>
  <body>...</body>
</html>

Start the Checker manually by clicking a button

In this example the Checker is not started automatically. Instead, a button is displayed on the WEBSITE that starts the Checker when clicked.

All content is manually blurred by the WEBSITE and unblurred when the VISITOR is verified.

html
<!DOCTYPE html>
<html lang="en">
  <head>
    ...
    <style>
      .blur {
        filter: blur(10px);
      }
    </style>
  </head>
  <body>
      <!-- Explicit image blurred by the WEBSITE -->
      <img class="blur" src="explicit_image.jpg" />

      <!-- Button to start the Checker -->
      <!-- Disabled by default, enabled when the Checker is loaded -->
      <button onclick="window.ageverif.start()" disabled>Verify your age with AgeVerif</button>

      <!-- Register functions -->
      <script>
        // Unblurs all blurred elements
        window.ageverifSuccess = function () {
          document.querySelectorAll('.blur').forEach((el) => el.classList.remove('blur'));
        };

        // Called when the Checker is loaded
        window.ageverifLoaded = function ({ verified }) {
          if (verified) {
            // Unblur the content if the VISITOR is already verified
            ageverifSuccess();
          } else {
            // Enable the button if the VISITOR is not verified
            document.querySelector('button').removeAttribute('disabled');
          }
        }
      </script>

      <!-- Load AgeVerif Checker -->
      <script src="https://www.ageverif.com/checker.js?key=[KEY]&nostart&onload=ageverifLoaded&onsuccess=ageverifSuccess" async defer></script>
  </body>
</html>