Hi everyone, I am working on a multi-tenant application setup where users can access:
customer1.example.com
for Customer 1's tenantcustomer2.example.com
for Customer 2's tenant- And so on
In my code, I have a tenant
variable that is sent to Amplitude, as shown below:
useEffect(() => {
if (!userId || !tenant) {
return;
}
amplitude.init(AMPLITUDE_ID, { userId });
const identifyEvent = new amplitude.Identify();
identifyEvent.setOnce('tenant', tenant);
amplitude.identify(identifyEvent);
}, [userId, tenant]);
I am using @amplitude/analytics-browser
version ^2.11.2
. This works well for our custom events when triggered (like page load or button clicks) as the tenant
property is included.
However, we also have Amplitude's autocapture enabled, which captures two initial events on page load that lack the tenant
property:
[Amplitude] Start Session
- missingtenant
[Amplitude] Page Viewed
- missingtenant
Page Load View
- includes bothtenant
anduserId
See the screenshot for more detail
When session start and the first Page Viewed event, tenant
didn’t get sent as expected

When I send my custom event Home Page Load, tenant
is being sent as expected

Question: Is there a way to delay Amplitude initialisation until a certain user property, like tenant
, is set? Or are there alternatives to ensure these autocapture events include tenant
?
Without this, we risk having a large amount of data that is missing the tenant
, which is problematic for our multi-tenant analytics. Thanks so much for all of your help!
What I have try so far
I noticed in the documentation that trackOn
can be used for conditional autocapture. I attempted the following code to ensure Page Viewed
events only trigger when both tenant
and userId
are available. However, I still see events being sent without the tenant
, so this does not seem to work as expected.
Documentation reference: https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2#track-page-views
amplitude.init(AMPLITUDE_ID, {
userId,
autocapture: {
pageViews: {
trackOn() {
return Boolean(tenant && userId);
},
},
},
});