Solved

Snapshot of subdomain on first page visit

  • 1 February 2023
  • 5 replies
  • 124 views

Userlevel 1
Badge +1

We use multiple sub-domains to identify traffic coming in for different third parties we hold a relationship with.  So end users will access the site via a link that looks something like:

https://third-party-x.ourdomain.com

or

https://third-party-y.ourdomain.com

I want to filter events according to which third party it is.  Later events include [third-party=third-party-x] in the event property hierarchy.  So I have two questions if anyone can help:

  1. How do I filter the initial events (e.g. get a count of how many users land by third party)
  2. How do I access the third party name in the hierarchy (I’ve read all the tutorials on snapshotting and can’t find the right form).

Any help gratefully received.  Thanks!

icon

Best answer by Nora-Heap 2 February 2023, 22:19

View original

5 replies

Userlevel 3
Badge +2

Great questions:

  1. How do I filter the initial events (e.g. get a count of how many users land by third party)

We autocapture a property on all pageviews, domain, that captures the entire subdomain. That can be used as a filter or group by for events in reporting to see users per subdomain. 

The one catch is if you want to analyze sessions you need to use a different property. Use the landing page property whenever analyzing sessions to see traffic by subdomain.

Note that the domain property captures the full domain (third-party-x.ourdomain.com), and landing page may be capturing some unique paths as well. If you want to see the data by just the third party name, you can create a defined property that uses a Regular Expression to pull out only the subdomain from either the domain or the landing page property values. The benefit of this approach is you get cleaner data. And this property is retroactively applied to historical data because it is built with autocaptured data! 

The defined property will look something like this! Let me know if you want some help with that or have questions about this.

  1. How do I access the third party name in the hierarchy (I’ve read all the tutorials on snapshotting and can’t find the right form).

I first recommend seeing if you can use the Domain autocaptured property (or a defined property that extracts the third party name from the domain property) in your analysis. If that property is available in the drop downs and is the format you want, that’s all you need!

If you want to extract the third party name from the hierarchy, then you can create a defined property that uses a regular expression to take it out from the hierarchy property instead. The key here is there needs to be a consistent pattern from which the third-party name appears in the hierarchy (it appears that is true! [third-party=third-party-x]).

Again, I recommend first trying to use Domain since it’s a simpler approach. That said, I’m happy to help you with the specific hierarchy example if needed.  

You may already know regular expressions pretty well, but if this is new to you here are a few resources I recommend checking out to learn more:

  1. Heap’s documentation on Regular Expressions in defined properties
  2. https://regex101.com/ - I always use this when creating and testing out a regex before adding it to a defined property in Heap. Awesome validation tool.  
  3. Datacamp’s RegEx Cheat Sheet - there are many of these floating around, here is one that looks good!

I’m also happy to workshop and provide some validation tips you can use in Heap for properties you create. :) 

Userlevel 1
Badge +1

Hi Nora, that’s super helpful, thanks!

I’ve added the property as suggested using the following regex:

It’s more complex than it needs to be for this specific use case, but it covers all bases from the posts I’ve read.  I’ve tested it on regex101 and it seems to work fine.

I must be doing something wrong though as the property is showing as having ‘No data from the past seven days’.  Is there something I need to do to enable it, or to retrospectively apply it to existing events?

PS That was odd - this editor clearly uses some kind of markup as when I post the regex as text - /(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/i - everything after it is struck out.

Userlevel 3
Badge +2

Hey Matt!

Sorry about the problems you are experiencing with the editor. I took a quick look in your account to see what was going wrong. The first thing I did was graph pageviews and group by the domain property to see the domain values. The problem is that Heap is not capturing “https://” in the Domain property. Since that’s what the regular expression was looking to match from the start, the regular expression was not matching any of the data. I updated the regular expression to be this:

([A-z\-]*)\.retirementandlifestyleplanner\.co\.uk

This new property is grabbing the first part of the subdomain now. Let me know if this is what you’re looking for, and if you have any questions about the things I did to modify it!

Userlevel 1
Badge +1

Hi Nora, not a problem about the editor.

That’s excellent support - many thanks for the speedy response and resolution.  Great stuff!

Userlevel 3
Badge +2

Sure thing! Happy reporting 😊

Reply