Skip to main content
Skip table of contents

CDP - Metering - Callback Function

Take full control of your metered content with the callback function option found in the Message Content step of a Meter. This feature enables developers to integrate a custom JavaScript function that ensures hidden content is revealed only after a meter is properly bypassed. We’ve added this feature to address cases where web-savvy users were able to bypass the gate through alternative routes, gaining access to content without proper authorization. By requiring the function to be called for content visibility, this enhancement strengthens access control and ensures an even more reliable metering experience.

image-20250131-175332.png

How does it work?

The callback function option found in the Message Content step of a Meter, allows developers to call a custom JavaScript function when the meter is bypassed. This function, which will need to be created by the webpage developer, ensures that the content hidden behind the meter is only displayed when the function is explicitly triggered. The function will only be triggered when:

  • a non-blocking meter is closed out of

  • a blocking meter is successfully bypassed

Check out this example:

https://olytics.omedastaging.com/olytics/staging/acme/articles/resources.html

You will notice the content is completely hidden from view until you either close out the first non-blocking meter message and after completing the registration form on the second blocking meter message. The content is only displayed once the user does one of the above actions (when the function is called).

The function name on this example is giveArticleAccess and the sample JavaScript can be found below:

CODE
function giveArticleAccess(){
      const section = document.getElementById('sec-9de6');
      section.style.display = 'block';
}

To use the callback function option:

  1. Work with the webpage developer to have a function added to the webpage where the Meter lives.

  2. Make sure to grab the function name from the developer.

  3. Navigate to Step 5 Message Content step of the Meter.

  4. Select the “Use callback function when meter is bypassed” option.

  5. Enter the function name in the Function text box.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.