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 we can use it in the Audience to target only PDPs. See below how the 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 we found an element with a class named product-description. We can use this to set the Audience and then we can test the 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 clicking Add and then click on the 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, We'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 clicking the dropdown after the input field and choosing how strict you want the check to be and then enter the text to check for in the input field after the select. To also check for a text in the element is however seldom necessary and we would rather recommend you to write a stricter CSS selector (maybe add a parent element or two).
Note: Remember to both click Save & close and also Save in the upper right after you set your Audience statement(s).
With the setup above the project will only target visitors that visit a PDP on the website. This means that the changes in the project will only happen on these pages and also that only these visitors will be tracked from now on. Any goal that is set up in the project will be able to be triggered from now on.