Problem with Target Audiences and Profile Scripts | Community
Skip to main content
Level 1
March 30, 2026
Question

Problem with Target Audiences and Profile Scripts

  • March 30, 2026
  • 1 reply
  • 11 views

i need to create a profile script to identify the last visited bike pdp by a visitor in real time and using that create an audience accordingly for each bike models mutually exclusive

1 reply

Adobe Employee
March 30, 2026

You can do this with a single Target profile script that stores the last bike PDP model, then build one audience per model off that script so they’re mutually exclusive. Because profile scripts run on every Target call before audience evaluation, the audience qualifies in (near) real time as soon as the visitor hits a bike PDP (see Script profile attributes).

1. Profile script 

Create a new profile script in Target > Audiences > Profile Scripts called last_bike_model:

// PoC: store last visited bike PDP model
// Assumes bike PDPs contain "/bikes/" in the URL and send entity.id or bikeModel

if (mbox.name == "target-global-mbox" && page.url.indexOf("/bikes/") > -1) {
// Try standard product id first, then custom param as fallback
var model = mbox.param("entity.id") || mbox.param("bikeModel");

if (model) {
// Normalize a bit so audiences can match reliably
return model.toString().toLowerCase();
}
}

// No new bike PDP on this hit → keep the previous value
var existing = user.get("last_bike_model");
if (existing) {
return existing;
}

Adjust the PDP detection logic to match your site:

  • Replace "/bikes/" with your actual bike PDP path segment.
  • If you don’t have entity.id, pass a bikeModel mbox/Web SDK param and rely on that.

Target automatically exposes this script as user.last_bike_model in the audience builder (see Profile attributes).

2. Mutually exclusive audiences per bike model

Now create one audience per model, for example:

  • Audience “Last bike PDP = Panigale V4”

    • Rule: Visitor Profile → user.last_bike_model equals Panigale V4
  • Audience “Last bike PDP = S1000RR

    • Rule: Visitor Profile → user.last_bike_model equals S1000RR
  • …repeat for each model you care about.

Because the profile script holds a single “last model” value, these audiences are naturally mutually exclusive: at any given time a visitor can only qualify into one “last bike PDP” audience.

You can now use those audiences directly in XT/AB/Recs activities to trigger bike-specific personalization based on the most recently visited PDP.