NathanBrownDigital of NBDigital
4/19/2020 - 1:11 PM

PREB events

PREB events

/* User Actions */
// User Login success
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'userLogin',
    userID: 'ContactGUID',
    loginStatus: 'loggedIn'
  });

// User Registration success
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'userRegistration',
    userID: 'ContactGUID',
    loginStatus: 'loggedIn'
  });

// User Logged Out
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'userLoggedOut',
  loginStatus: 'loggedOut',
  userId: 'ContactGUID' // the ContactGUID cookie empties upon logout - this allows us to persist ContactGUID to analytics for remarketing purposes & identifying registered users visiting the site when logged out to stitch logged out sessions to the user, define remarketing audiences, and display proper dynamic content such as chatbot flows
});

/* Form Submissions - events to fire when the given form successfully submits */

// Generic "Contact" form (contact agent, contact broker)
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'formSubmitted',
    formId: 'contactForm',
    contactTarget: 'Broker' // replace with agent name if the generic contact form is for contacting a specific agent, like on the agent's subdomain

/* Search Events */

// Quick Search success
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'quickSearch',
    searchQuery: '{searchQuery}' //input axctual query, as typed
  });

// User saves a search
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'searchSaved',
    searchName: '{search name}', //input the name of the saved search - this information will be hashed in GTM in case users put PII in the search name
    searchAlerts: '1 day' // input email frequency, or "none"
  });

/* Listing Events */
// User Saved Listing
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'listingSaved',
    listingID: 'MLS', // optional, we can also pull this from the cookie using GTM if that's simpler
  });

// Request Details on a listing form success - same event for request details model & listing page requwest details form
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    event: 'formSubmitted',
    formId: 'requestDetails',
    listingID: 'MLS',
    requestShowing: 'true|false' // Boolean - true only if they checked "Schedule a Showing"
  });