Need to including and excluding evar in the same hit | Community
Skip to main content
Level 2
February 23, 2026
Question

Need to including and excluding evar in the same hit

  • February 23, 2026
  • 1 reply
  • 23 views

On our site we have the following :
each evar below expires on visit

category Level 1 page → evar1 is set on that page
category Level 2 page → evar1 and evar 2 are set on that page
category Level 3 page → evar1, evar2 and evar3 are set on that page
category Level 4 page→ evar 1, evar2, evar3 and evar4 are set on that page

category Level 5, up to 6 follow the same structure as above

I want to see page views for category Level 3 pages only as well conversion rate for visits who have seen category Level 3 but not any of the other pages.
 

i have tried building a hit segment with a container (hit) that includes evar3 exists and is set and within that same hit container, I added an exclude hit container(excludes evar 4, 5 and 6) but the data returned shows that my segment does not work.

 

While I would expect to see only Level 3 pageNames in that segment , I am seeing all kinds of pages.

What is the solution?

 


 

    1 reply

    DanIMS1
    Level 3
    February 23, 2026

    Hi,

    From my understanding of your issue, you are setting eVar 3 for category level 3 pages and higher.

    This means any segment that is hit-based and includes eVar 3 will include category levels 3, 4, 5 and 6 pages. If you combine this segment with a hit container that excludes hits with eVars 4, 5 and 6, and you don’t use the OR operator in the container, it will only exclude hits that contain eVar 4,5, 5 and 6.

    As you are using eVars, you should be aware of the persistence settings. If your eVars don’t expire on the hit or pageview, they will persist across pages. This means that if a user hits a category level 3 page, then a category level 2 page, the category level 2 page will fall within the segment.

    To stop this, make sure your hit-based container is an eVar 3 instance that exists, not just eVar 3 exists. This will ensure that you are only showing the pages where eVar 3 is set. Similarly, you should use eVar 4, 5 and 6 instances in your exclude container to counteract the persistence.

     

    Your segment should be:

    container 1 (hit-based): {

    eVar 3 instance exists

    }

    AND

    container 2 (hit-based exclude):{

    eVar 4 instance exists OR eVar 5 instance exists OR eVar 6 instance exists

    }

     

    Hope this helps,

    Dan

    Level 2
    February 23, 2026

    Thank you Dan.

    You wrote: “If your eVars don’t expire on the hit or pageview, they will persist across pages. This means that if a user hits a category level 3 page, then a category level 2 page, the category level 2 page will fall within the segment.”

    The segment I am trying to build should return visits where a user has seen only the category level 3 pages so in theory, there should not be any category level 2 pages included in the segment because the user would never have seen any category page (Except 3).


    I had tried to build the segment you are suggesting but it did not seem to work. It returned many pages, that were not exclusively category Level 3.

    DanIMS1
    Level 3
    February 23, 2026

    Is your page’s dimension a prop, an eVar, or the default page dimension?
    Test the segment by making a table with the following columns:
    occurrences, and the eVar instances of eVars 1-6, then have the repeat the columns but below the segment.
    For your rows have set the page dimension you are using.

    Your occurrences, evar 1 and evar 2 instances under the segment, should match the evar 3 instances. 
    The other values under the segment should just say 0. 

    If you are seeing any other numbers for eVars 4-6, then the segment isn’t correct, as it should be excluding these hits. 

    If you are seeing page values that are have eVar 3 instances, then that would imply the implementation isn’t setting the page value when evar 3 fires and the previous value is being carried over to this instance.

    Here is a simplified version of the segment and table using some mock data.
     

     




    If you are doing a return visit segment, then this segment would need to be used within a visitor-based segment to show people who have fallen within this segment then returned to the site. But then you will see pages that don’t belong to the category level 3 pages if the user, in subsequent visits, saw pages from the other category levels.