Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So, I am looking to add a tag that I want to use for A/B testing, however we don't have a page-type URL structure. Fortunately the tool can recognise page type if I pass it by Javascript.

<script type="text/javascript">
window.isProductPage = true;

I have been told to use the above, I have created the script in Google Tag Manager (GTM), however I now need to know how to make this run on those pages in GTM.

I have looked through the code and there are div class that are unique to each page, can I use this as an indication of page type?

share|improve this question

So I found a workaround using the GTM Data Layer.

The Data Layer passes values from the page to GTM, within that I had a Brand variable - this wouldn't populate on any page other than Product detail pages.

I could then create the rule where Brand wasn't null using RegEx.

This script now runs on Product Pages only.


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.