• Retrieves and validates stored GAD parameters for a specific service.

    This function reads a serialized UTM object from sessionStorage under the key defined by GAD_STORAGE_KEY. It ensures that:

    • The stored object exists and is valid JSON.
    • The GAD data has not expired (based on its expiry timestamp).
    • The stored landing page corresponds to the provided service
    • which basically means the gad should be related to the service which this mapping is declared in URL_TO_UTM_SERVICE_MAP or it returns null.

    If any of these checks fail, the function clears the stored data and returns null.

    Parameters

    • service: UTM_SERVICES_ENUM

      The service identifier to validate the stored GAD data against.

    Returns Record<string, any> | null

    The parsed GAD parameters object if valid, or null if expired, mismatched, or invalid.

    import getGADParams from '@/functions/get-gad-params';
    import { UTM_SERVICES_ENUM } from '@/constants/utm';

    const gad = getGADParams(UTM_SERVICES_ENUM.INSURANCE_BODY);
    if (gad) {
    console.log('Valid GAD parameters related to insurance body service:', gad);
    } else {
    console.log('No valid GAD data found.');
    }