checkAudienceMembership

❗️

Deprecated

This method is no longer recommended. Audience Manager is no longer available in the latest product version.

The checkAudienceMembership() method checks if a user belongs to a specific audience.

Syntax

const audienceId = 'audienceId';
const isMember = await PiwikProSdk.checkAudienceMembership(audienceId);
console.log(isMember);
// true

Parameters

audienceId (string, required)

The ID of the audience you want to check. You can find it in Data Activation > Audiences.

Returns

Whether the user is a member of the audience.

A boolean value.

  • true: The user is a member of the audience.
  • false: The user isn’t a member of the audience.

Examples

To check if a user belongs to an audience:

const audienceId = 'a83d4aac-faa6-4746-96eb-5ac110083f8e';
const isMember = await PiwikProSdk.checkAudienceMembership(audienceId);
console.log(isMember);
// true

Related methods