Skip to content
Cornelius Horstmann edited this page Jan 27, 2019 · 4 revisions

Frequently asked questions

In the backend devies are just shown as "Apple iPhone". How do I get more information such as specific device or OS version?

Update: Starting in version 5.2 the Matomo iOS SDK updates the default User Agent, so that instead of just "Apple iPhone" it automatically sets the device.humanReadablePlatformName so there is no need to add a Custom Dimension in order to track the specific device.

Matomo automatically extracts some information from the User Agent. This is how it knows it was an "Apple iPhone". If you want to add more detail you can use the Custom Dimension feature. To do that, you have to add these custom dimensions in the backend and then set them in your application using the set(value:forIndex) function. The index references your configured custom dimension in the backend.

let application = Application.makeCurrentApplication()
let device = Device.makeCurrentDevice()
MatomoTracker.shared.set(value: device.humanReadablePlatformName ?? device.platform, forIndex: 2)
MatomoTracker.shared.set(value: application.bundleShortVersion ?? "unknown", forIndex: 3)

How to use the MatomoTracker from Objective-C

Version 4 (and higher) of this SDK is written in Swift, but you can use it in your Objective-C project as well. If you don't want to update you can still use the unsupported older version 3. The Swift SDK exposes Objective-C compatible API for most functionality so using it from Objective-C should be pretty straight forward in most cases.

If the MatomoTracker is the first Swift library in your project there is a little configuration needed.

  • Add a random .swift file to your project.
  • In you main target select the Swift version to 4.2
  • perform a pod install
MatomoTracker *matomoTracker = [[MatomoTracker alloc] initWithSiteId:@"5" baseURL:[NSURL URLWithString:@"http://your.server.org/path-to-matomo/piwik.php"] userAgent:nil];
[matomoTracker trackWithView:@[@"example"] url:nil];
[matomoTracker trackWithEventWithCategory:@"category" action:@"action" name:nil number:nil url:nil];
[matomoTracker trackSearchWithQuery:@"custom search string" category:@"custom search category" resultCount:15 url:nil];
[matomoTracker dispatch];
matomoTracker.logger = [[DefaultLogger alloc] initWithMinLevel:LogLevelVerbose];
[matomoTracker trackCampaignWithName:@"campaign_name" keyword:@"campaign_keyword"];
matomoTracker.userId = @"Just a custom id";