Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

The events that you log must be objects, however they can take any form that you like. You should put some thought into what values you will log from an event, keeping in mind that you'll most likely want to categorise the data for display purposes later.


The following is an example of a single event object, with a multitude of values included. It's important to note that you can pass whatever values you please into these events:

// Format your event
const formattedEvent = {
  category: "Videos",
  action: "Start",
  label: "HowTo",
  value: Date.now()
}



To send a single custom event, using the logEvent() method, and the formattedEvent object we configured previously:

// Log your event
collector.logEvent("Server CLI Request", formattedEvent)
  .then((analyticsEvent) => {
    // The logEvent() method returns a Promise
    // that resolves to the event
    // sent to the analytics service
    console.log(analyticsEvent)
  })
  .catch((err) => {
    throw Error(err)
  })



To send multiple custom events at once, we format our single events into an array of events, and use the logEvents() method:

// Format your events into an array
const formattedEvents =
[
  {
    category: "Videos",
    action: "Start",
    label: "HowTo",
    value: 1497509263823
  },
  {
    category: "Videos",
    action: "Stop",
    label: "HowTo",
    value: 1497509350209
  }
]

// Log your events
collector.logEvents("Server CLI Request", formattedEvents)
  .then((analyticsEvent) => {
    // The logEvents() method returns a Promise
    // that resolves to whatever was
    // returned from the Simple Analytics service,
    // currently the array of events that
    // was sent to Simple Analytics
    console.log(analyticsEvent)
  })
  .catch((err) => {
    throw Error(err)
  })


Congratulations! When this script is triggered, your custom events will now be logging to the BlinkMobile Simple Analytics Service Database.


From there, your events can be accessed with MongoDB queries using our Dashboard Console. For more information, please see the link under Further Reading.

Further Reading

Analytics Console: Displaying Your Analytics Data with a Dashboard

  • No labels