iOS Event tracking and analytics with JustTrack

Federico Cappelli
3 min readApr 5, 2018

--

JustTrack by Just Eat

Overview

At Just Eat, tracking events is a fundamental part of our business analysis and the information we collect informs our technical and strategic decisions. To collect the information required we needed a flexible, future-proof and easy to use tracking system that enables us to add, remove and swap third-party SDK integrations with minimal impact on our applications’ code. We also wanted the required event metadata to be kept up-to-date automatically whenever the requirements changed.

JustTrack is the event tracking solution we built and its available open source on Github at github.com/justeat/JustTrack.

Examples and documentation are available in the Github repository Readme.

Main features

  • Events are declared in a .plist file and the Swift code is automatically generated at build time from it.
  • Events can be sent to multiple destinations (called Trackers) at the same time.
  • Custom Trackers are easy to create and use.
  • Immediate or batch dispatch are supported.

Events Definition

One of the problems we found with existing solutions is that the events are declared in code and therefore can only be maintained by developers. Similarly, existing solutions offer very generic tracking facilities.

Therefore, whenever the required metadata associated with an event changes for any reason, the developer has to search the code and update all instances of the event with the correct implementation. This is of course a very fragile manual process and increases the risk of errors.

JustTrack solves these problems by declaring events in a .plist file which is used to automatically generate equivalent definitions of the events in Swift, that can then be used in the app.

This Swift code is generated automatically

This approach has several benefits:

  • Each event is uniquely identified.
  • The event payload is type checked.
  • When the requirements for an event change, the developers can see it through build errors and warnings that will automatically occur.
  • The .plist files can be edited as XML which means anybody in the business can edit them.
  • It’s easy to search for events that are no longer used. Using a deleted event won’t compile.

An Event is made of:

  • Name: the unique identifier.
  • Registered Trackers: a list of event destinations (e.g. Google Analytics).
  • Payload: the metadata associated with the event (at this time only string key-value pairs are supported).

Trackers

Another problem we found with existing solutions is that, generally speaking, all the events need to be tracked with the same Trackers. The developer doesn’t have any freedom to decide which event goes to which Tracker, and several solutions only support specific tracking technologies (such as GA, Firebase, and so on).

JustTrack solves this problem by allowing the developer to specify the “registered” trackers for each event and to create custom trackers.

A simple JETracker implementation

A Tracker is an object implementing the JETracker protocol and is loaded using the following function: tracker.loadCustomTracker( ... )

You can implement any tracker you want and JustTrack provides the JETrackerConsole that simply prints events to the system’s console.

Conclusions

JustTrack requires minimal coding and enables you to track your app’s events in multiple destinations with ease, providing you with flexibility, intrinsic event documentation and the capacity to expand.

Original post https://tech.just-eat.com/2017/02/01/ios-event-tracking-with-justtrack/

--

--