docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Configure a Nuxt.js application to support Google Analytics tracking for a multi-tenant SaaS platform where each client organization has its own tracking ID.
The application needs to:
You're building a multi-tenant SaaS application where multiple client organizations use the same codebase. Each organization needs their own Google Analytics tracking to monitor their users' behavior independently. The tenant information, including the analytics tracking ID, is stored in a database and needs to be fetched at runtime.
An API service is already available with the following method:
// services/tenant-api.js
export async function fetchTenantConfig(tenantId) {
// Returns: { analyticsId: 'UA-XXXXXX-X', name: 'Client Name', ... }
const response = await fetch(`/api/tenant/${tenantId}/config`);
return response.json();
}The tenant ID is available in the Nuxt context via context.route.query.tenant or can be read from context.$config.tenantId.
nuxt.config.js to support dynamic tracking ID loadingProvides Google Analytics integration for Nuxt.js applications with support for dynamic configuration.