Skip to content

sentEventToSegmentio

Mike Byrne edited this page Jan 25, 2022 · 2 revisions

description

Tracks site wide requests for analytics events. Catches events before segment.io is ready, stores them and tries them again when it is ready. Follows conventions from segment.io: https://segment.com/docs/libraries/analytics.js/#selecting-integrations Checks a meta tag on init for identifying the user

requires

  • segment.io JS to be linked in the body

parameters

  • none

returns

  • nothing

example usage:

triggerCustomEvent('analytics',{
  type: 'track',
  name: 'Sponsor clicked',
  properties: {
    name: 'Coca-Cola'
  }
});

triggerCustomEvent('analytics',{
  type: 'page',
  category: 'videos',
  name: 'George Lucas',
  properties: {
    foo: bar
  }
});

triggerCustomEvent('analytics',{
  type: 'identify',
  userID: '1312',
  properties: {
    name: 'Mike Byrne',
    email: '[email protected]'
  }
});

Auto identify

Requires metatag:

<meta name='analytics_user_info' content='id:1312,name:Mike Byrne,email:[email protected]' />

Include what info you need.