Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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:

Code Block
languagejs
// 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:

Code Block
languagejs
// 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)
  })


Congratulations, 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

Displaying Your Collected Analytics Data in a Dashboard