How do I target all pages that match a pattern in Target's Page Delivery?
I'm needing to match 100's of pages that match like this for an A/B test:
example.com/path-name/
example.com/path-name/product-name
I tried example.com/* and example.com/*/* but it didn't work.
Thanks!
Topics help categorize Community content and increase your ability to discover relevant content.
Hi @Rajneesh_Gautam_ - I'm not familiar with this. Can you provide more information?
Thanks.
Here's an example by @Ryan_Roberts_ from another thread.
1. Create a profile script - sample code using Regex given below
2. Use the profile script within your audience definition of your activity
if (page.path.match(/basketball\/nba\/\w+?-|football\/nfl\/\w+?-/) !== null ||
'') {
return true;
} else {
return false;
}
Not sure if it's working, wrote this code and then created an audience for this. It doesn't seem to be working. Any further suggestions?
var urlRegex = new RegExp("^https://example\\.com(/pages)?/local/[a-zA-Z]+(/[a-zA-Z]+)?$");
var currentUrl = user.getLocal('pageURL'); // Assuming 'pageURL' is the variable that contains the full URL
// If the URL matches the pattern, set a profile parameter
if (urlRegex.test(currentUrl)) {
user.setLocal('profile.regexMatch', 'true'); // Sets a profile parameter 'regexMatch' to 'true'
} else {
user.setLocal('profile.regexMatch', 'false'); // Sets the profile parameter to 'false' if there is no match
}
I also have this as my audience setting:
You need to return true or false to the profile script in order for a value to be written to that key ...
LOCAL_PAGE_TARGETING
... return true
The setLocal variables are used for temp storage of values to be assessed.
Hi @JPFiber
In Adobe Target, to target multiple pages that match a specific pattern, you can use regular expressions in the URL targeting section. Regular expressions allow for more flexible and precise matching of URLs.
For your case, where you want to target pages with URLs like example.com/path-name/ and example.com/path-name/product-name, you can use a regular expression like:
^https?:\/\/example\.com\/path-name(?:\/.*)?$
Here's what this regular expression does:
^ asserts the start of the line.
https? matches both "http" and "https".
:\/\/example\.com\/path-name matches the literal string "://example.com/path-name".
(?:\/.*)? is a non-capturing group that matches an optional forward slash followed by any characters.
$ asserts the end of the line.
This regular expression matches URLs that start with https://example.com/path-name/ and may optionally have additional characters after /path-name/.
To set up this targeting in Adobe Target:
Navigate to your A/B test in Adobe Target.
Go to the targeting section.
Choose URL as the targeting dimension.
Select "Matches Regular Expression" as the operator.
Enter the regular expression: ^https?:\/\/example\.com\/path-name(?:\/.*)?$
This setup will target all URLs that match the specified pattern. Make sure to test your regular expression thoroughly to ensure it's capturing the desired URLs correctly.
Views
Like
Replies
Views
Likes
Replies