Analytics - Sample Swift (iOS) App and Tutorials

Important

Visual Studio App Center is scheduled for retirement on March 31, 2025. While you can continue to use Visual Studio App Center until it is fully retired, there are several recommended alternatives that you may consider migrating to.

Learn more about support timelines and alternatives.

In this tutorial, you'll learn to view custom events and other user analytics in App Center. Code to track these events is included in the sample Swift app.

If you haven't already, first follow the getting started tutorial to set up the sample Swift app.

Open the app and view user Analytics

To see users, session, and other information on the Overview page:

  1. Run the app using .xcworkspace, or from your device.

  2. Interact with the sample app from the simulator or device.

  3. Go to the Analytics service in App Center. There may be a short delay before the page is updated.

Send and view custom events

  1. In the sample app, press the Send a sample event button.

  2. In the sample app, press the Send event with color property button. Choose a color.

  3. Navigate to the Analytics service in App Center and go to the Events section.

  4. You should see data for both the sample and color event buttons. Click on the color event to see that the color you chose has been pressed at least once.

In App Center, you can view detailed analytics about both buttons by clicking on the events, and even see how many people chose each color.

To make this possible, code from the App Center SDK is included. It will specifically track when these buttons are pressed. These custom events can have multiple properties - in this case, the color chosen is an event property.