Skip to main content
Skip table of contents

Web Analytics Integration

This page contains integration guides with various Web Analytics solutions, of how to pass martechpass as declared ID.

Why Integrate Utiq martechpass with Analytics?

The Utiq martechpass (mtid) is a semi-stable identifier tied to a real person (or household), persisting across browsers and devices, and rotating every 90 days for privacy and compliance.

When passed as a user ID in Web Analytics, it helps stabilize and unify visitor metrics.

Primary Use Case

  • Metric Stabilization & Deduplication: More accurately measure Unique Users by reducing identity fragmentation across devices or browsers.
    For example, instead of reporting 1.000 ‘visitors’ (duplicate cookies), analytics may reveal 900 true individuals using martechpass, and report a more realistic and stabilized conversion rate.

For more on use cases, visit: Utiq Use Cases

Vendor Integrations

For each integration, Utiq recommends retrieving the mtid using onIdsAvailable via the addEventListener API, especially when embedding via third-party scripts.

Google Analytics (GA4) via GTM

CODE
window.Utiq ||= {};
window.Utiq.queue ||= [];

const handleIdsAvailable = ({ mtid }) => {
  // Callback action for onIdsAvailable
  if (window.dataLayer && Array.isArray(window.dataLayer)) {
    window.dataLayer = window.dataLayer || [];
    
    window.dataLayer.push({
      event: 'utiqUserIdReady', // Optional: custom event name for triggers
      user_id: mtid
    });
  } else {
    console.error('Google Tag Manager is not available.');
  }
};

window.Utiq.queue.push(() => {
  window.Utiq.API.addEventListener('onIdsAvailable', handleIdsAvailable);
});

Google Tag Manager configurations to pass martechpass as User ID in GA4

  • Create a data layer variable

    • In Google Tag Manager, click Variables

    • In the User-Defined Variables section, click New

    • Click Variable Configuration > Data Layer Variable

    • Enter a name for the variable at the top

    • In the Data Layer Variable Name field, enter a name for your user ID (e.g. "user_id")

    • Click Save

  • Modify your Google Analytics 4 tag

    • In Tag Manager, click Tags

    • Select your Google Analytics 4 tag

    • Under Configuration settings section, add a new row with the following parameters:

      • Parameter: user_id

      • Value: Select the Data Layer variable you created

    • Click Save

    • Click Submit to publish the changes

Documentation: https://developers.google.com/analytics/devguides/collection/ga4/user-id?client_type=gtm

Testing: In Console type window.dataLayer and check for utiqUserIdReady event. Also filter Network for collect and check attribute uid

Marfeel

CODE
window.Utiq ||= {};
window.Utiq.queue ||= [];

const handleIdsAvailable = ({ mtid }) => {
  // Callback action for onIdsAvailable
  if (window.marfeel && window.marfeel.cmd && typeof window.marfeel.cmd.push === 'function') {
    window.marfeel.cmd.push(['compass', function(compass) {
      compass.setSiteUserId(mtid);
    }]);
  } else {
    console.error('Marfeel is not available.');
  }
};

window.Utiq.queue.push(() => {
  window.Utiq.API.addEventListener('onIdsAvailable', handleIdsAvailable);
});

Documentation: https://community.marfeel.com/t/user-reconciliation-tracking/11388

Testing: Filter Network for ingest and check attribute sui

Piano Analytics

CODE
window.Utiq ||= {};
window.Utiq.queue ||= [];

const handleIdsAvailable = ({ mtid }) => {
  // Callback action for onIdsAvailable
  if (typeof pa !== 'undefined' && typeof pa.setUser === 'function') {
    pa.setUser(mtid);
  } else {
    console.error('Piano Analytics is not available.');
  }
};

window.Utiq.queue.push(() => {
  window.Utiq.API.addEventListener('onIdsAvailable', handleIdsAvailable);
});

Documentation: https://developers.atinternet-solutions.com/piano-analytics/data-collection/how-to-send-events/users

Testing: Filter Network for collect or pa and check attribute user.id

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.