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 Audience Manager > Audiences.

Returns

A boolean value, true if the user is a member of the audience, false otherwise, instead of a string that describes the method and its parameters.

Examples

To check if a user belongs to an audience:

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

Related methods