Target pages that have the same structure
Let's say you want to make changes to all PDPs (Product Detail Page). These pages have the same HTML structure and differ only in text and images. To be able to do this you need to set up an Audience that targets only these pages (and not any other page on the website).
Target by URL
The first thing you can check for is if the URL to these pages contains something unique that you can set Audience to.
Sometimes, like in this example, the URL may contain a word or characters that will only exist in the URL on these specific pages. In this example, I know for a fact that the character combination /p/ only exists on PDPs. This means I can use it in my Audience to target only PDPs. See below how my Audience is set up for this.
Difference between Exact match, Simple match, Contains & Regex
Target by Page Content
If you do not have this type of structure in your URL and can not use the URL to target the specific pages you want, you can check for unique page content instead. To do this simply open up a preview for your project, then navigate to a PDP, and then right-click on an element that you believe would be unique to all these pages, and then choose Inspect.
This element should in other words be one you believe would not exist on PLPs, the home page, checkout, or any other page of the website (that isn't a PDP).
A good guess for this example is the product title, the product information container, the buy button, or maybe the product image. Note that all of these elements might exist elsewhere so you better make sure the element you select is unique to only PDPs.
When you click Inspect the browser will bring up developer tools and mark the element you clicked on (see image below). This allows you to check out the HTML structure of the page. If you are in luck you will see either a Class or an ID on an element that you can use to target your Audience.
In the example below I found an element with a class named product-description. I can use this to set my Audience and then I can test my Audience to make sure that the element does not exist on any other page (where I don't want my changes to happen)
You add this in Audience by dragging a Page Content statement and then adding this as you would write normal CSS selectors
In other words, class names are added with a dot ( . ) before the name and IDs are added with a hashtag (#) before the name.
In the example, I've added the class name product-description as a Page Content value (see image above). If you need to you can also check for a text value in that element by adding this in the second input field and choosing how strict you want the check to be in the dropdown to the left of this input field. To also check for a text in the element is however seldom necessary and I would rather recommend you to write a stricter CSS selector (maybe add a parent element or two).
Note: Remember to click Save Audience after you add your Audience statement(s).
With the setup above I will now only target visitors that visit a PDP on the website. This means that my changes will only happen on these pages and also that we will track the visitor from now on. So any goal you've set up for this project will be able to be triggered from now on.
See our Video academy for more Audience examples