Meta Signals Gateway: JavaScript Code for Event ID

Meta Signals Gateway

You can find the custom JavaScript code for the Google Tag Manager Event ID variable below.

Important: You will need to change the ID included in the code to reflect the container it is installed it. Look for 'GTM-ABC123' and replace it with your container ID.

// IMPORTANT: Correct container ID needs to be included below
function() {
  var eventId = window.google_tag_manager['GTM-ABC123'].dataLayer.get('gtm.uniqueEventId');
  window._eventIds = window._eventIds || {};
  if (!window._eventIds[eventId]) {
    window._eventIds[eventId] = Date.now().toString(36) + Math.random().toString(36).substring(2, 10);
  }
  return window._eventIds[eventId];
}

Once you've added the code, your JavaScript variable should look something like this:

Custom JavaScript variable in Google Tag Manager for Event ID