Understanding mobile user behavior and tracking events within your app is crucial for delivering a better user experience. 


Breadcrumbs, a valuable tool provided by Embrace, can help you achieve just that. 


In this post, we'll quickly explore how to implement breadcrumbs in your iOS application using Embrace in order to gain insights into user sessions and improve your app's performance.

What are breadcrumbs?


Before diving into the implementation, let's briefly discuss what breadcrumbs are and why they matter. Breadcrumbs are lightweight, unobtrusive log messages that provide insights into user interactions within your app. These messages are especially valuable when tracking events that might not otherwise be visible in a session, but are still essential for understanding user behavior.


Implementing breadcrumbs in your iOS app with Embrace


To implement breadcrumbs in your iOS application using Embrace, you can use the `addBreadcrumb` method. Here's how you can add a breadcrumb to your app's session:


For Swift:

let msg = "Master table view editing mode did change to: \(editing), animated: \(animated)"

Embrace.sharedInstance().logBreadcrumb(withMessage: msg)



For Objective-C:


NSString *msg = [NSString stringWithFormat:"Master table view editing mode did change to: %@, animated: %@", editing, animated];  
[[Embrace sharedInstance] addBreadcrumbWithMessage:msg];



In the examples above, a breadcrumb is added to a sample application to track when the user enters and exits editing mode on a table view. This event might not be otherwise visible in the session but can be crucial in understanding what the user does next.


Remember that breadcrumb messages must be 256 characters or less — after this point, they’re truncated. The great thing about breadcrumbs is that they add very little CPU or memory overhead and trigger no networking calls, making them an efficient way to enhance your app's monitoring capabilities.


Best practices for using breadcrumbs


To make the most out of breadcrumbs, it's essential to follow best practices. Some key points to keep in mind include:


1. Keep breadcrumbs simple: If you need to search, filter, aggregate, or alert on this data in the future, then it should be a log instead. 


If this data provides additional context when reviewing a user session, it should be a breadcrumb. 


2. Focus on critical (but not too critical) events: Use breadcrumbs to track critical events or interactions within your app that are not easily observable through other means. Breadcrumbs are most helpful when they provide deeper technical context into the user session. 


If you need to be alerted to a critical event, then this should be a log rather than a breadcrumb.


3. Avoid overloading with breadcrumbs: While breadcrumbs are lightweight, too many of them can still clutter your session data. Use them judiciously.


Check out this post for additional information on when to use logs versus breadcrumbs


You can learn more about how to use breadcrumbs effectively by visiting Embrace’s best practices page here

Build better iOS experiences with Embrace


Incorporating breadcrumbs into your iOS application using Embrace is a smart move to gain deeper insights into user behavior and enhance the overall user experience. By logging essential events that may not be visible in your app's session data, you can make data-driven decisions to improve your app's performance and usability.


Learn more about leveraging Embrace to build better iOS experiences, here.