Skip to main content

Analytics and Advertising Setup

This guide explains how to set up Microsoft Clarity and Google Analytics for your eDemand web application.


Microsoft Clarity Setup​

Step 1: Get Your Clarity Project ID​

  1. Sign up for Microsoft Clarity:

  2. Create a new project:

    • Click "Add New Project"
    • Enter your website name
    • Enter your website URL
    • Select your country/region
    • Click "Create"
  3. Get your Project ID:

    • After creating the project, you'll see a tracking code snippet
    • Your Project ID is the string at the end of the script URL
    • Example: u5frguc1k8 (from https://www.clarity.ms/tag/u5frguc1k8) Microsoft Clarity project ID preview

Step 2: Set Your Project ID​

No code editing needed — just set the env var. Open .env.local (copy from .env.example if you haven't) and set:

NEXT_PUBLIC_CLARITY_PROJECT_ID=u5frguc1k8
note

The Clarity script only loads after the visitor grants analytics consent on the cookie banner — see src/components/layout/consent-scripts.tsx. It won't fire on page load even with a valid ID set.


Google Analytics Setup​

Step 1: Get Your Google Analytics Tracking ID​

  1. Sign up for Google Analytics:

  2. Create a new property:

    • Click "Admin" (gear icon)
    • Under "Property", click "Create Property"
    • Enter property name (e.g., "eDemand Website")
    • Select timezone and currency
    • Click "Next"
  3. Set up data stream:

    • Select "Web" platform
    • Enter your website URL
    • Enter a stream name
    • Click "Create stream"
  4. Get your Measurement ID:

    • After creating the stream, you'll see your Measurement ID
    • Format: G-XXXXXXXXXX (e.g., G-J4RWHNVBG0)
    • Copy this ID

Step 2: Set Your Measurement ID​

No code editing needed — just set the env var. Open .env.local and set:

NEXT_PUBLIC_GA_MEASUREMENT_ID=G-J4RWHNVBG0
note

Same as Clarity above — the GA script only loads after the visitor grants analytics consent (src/components/layout/consent-scripts.tsx). A Consent Mode v2 denied-default stub (pages/_document.tsx) also runs before this, so Google collects nothing until consent is actually granted.