Ready event

In cases where you would like to ensure that code runs after a tag has been initialized, you can use the ready event to register a callback that runs for every tag initialization.

In contrast to the edgetag-initialized HTML custom event, this callback will also be fired if the callback is registered after the tag has already initialized, guaranteeing that it will always fire regardless of when it is registered.

Properties

Property
Description

destination

EdgeTag URL for the tag that has been initialized

userId

user ID

sessionId

current session ID

isNewUser

true if this is the user's first visit to the site

isNewSession

true if this is the start of the user's session on this site

consent

Describes the user's consent configuration and is opt-in by default.

consentCategories

Describes the user's consent category configuration and is opt-in.

consentSettings

Describes the channel categories and whether consent is enabled for the tag.

Example

edgetag('ready', (params) => {
  if (params.isNewUser) {
    // this will only ever trigger once on first visit
    window.alert('Hello and welcome to our shop!')
  } else if (params.isNewSession) {
    // this will only trigger on subsequent visits once per session
    window.alert('Hi and welcome back to our shop!')
  }
})

Last updated

Was this helpful?