vercel / analytics

Privacy-friendly, real-time traffic insights
https://vercel.com/analytics
Mozilla Public License 2.0
422 stars 26 forks source link

Subdomain analytics #90

Open thibaultleouay opened 1 year ago

thibaultleouay commented 1 year ago

For openstatus we allow users to create subdomain hosted under our own domain

They are rewritten using next middleware

Is it possible to track this subdomain ? Maybe with before send function?

Does the event contains the full request hostname ?

tobiaslins commented 1 year ago

We're already tracking the full hostname but we don't expose a hostname filter/domain selector yet. Do you want to filter for a specific domain eg my.custom-domain.com and see all the pageviews/events from it?

thibaultleouay commented 1 year ago

yep that would do the job, I want to be able to differentiate the page views from our landing page www.openstatus.dev -> page / and custom-domain.openstatus.dev -> page /

What i thought of doing was something like these

<Analytics
  beforeSend={(event) => {
    if (event.host.includes('www')) {
      return event;
    } else {
    return {
      ...event,
      url: `/domain/${event.host}/${url.toString()}`,
    };;
    }
  }}
/>
thibaultleouay commented 1 year ago

This is how I managed it

https://github.com/openstatusHQ/openstatus/blob/main/apps/web/src/app/_components/analytics.tsx

In order to catch the custom subdomain

Their might be a better way ?

tobiaslins commented 1 year ago

@thibaultleouay looks good. for now this is the only way to "see" that data. We'll let you know once we add support for hostnames!

nikl216 commented 8 months ago

Hey, is there an update on this yet? I want to track analytics for a multi-tenant app. how do i do this ? Also the openstatus github link isn't working. Could you explain on how i can achieve this currently ?

thibaultleouay commented 8 months ago

@nikl216
We removed it from subdomain pages but you have achieve it like this : https://github.com/openstatusHQ/openstatus/blob/935787d332ea3f5ac36248ee1865e75790bc370e/apps/web/src/app/_components/analytics.tsx

diego-lipinski-de-castro commented 4 months ago

+1 for this feature, filter analytics by subdomain

everettglovier commented 3 months ago

im using multiple TLDs on a single project for localization (.com, .de, .fr) and cannot differentiate them in the analytics. this would be a very beneficial feature!