Can Page Delivery use RegEx | Community
Skip to main content
Level 3
February 22, 2024
Question

Can Page Delivery use RegEx

  • February 22, 2024
  • 2 replies
  • 2202 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Rajneesh_Gautam_
Community Advisor
Community Advisor
February 22, 2024

Hi @jpfiber - I will suggest using profile scripts that support regular expressions and use current page URL value. 

Thanks

Rajneesh

JPFiberAuthor
Level 3
February 22, 2024

Hi @rajneesh_gautam_ - I'm not familiar with this.  Can you provide more information?

Thanks.

Rajneesh_Gautam_
Community Advisor
Community Advisor
February 22, 2024

Here's an example by @ryanr7  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; }

 

Level 3
February 29, 2024

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.