Security, Privacy, AI and CSR information for all Piano products now lives in one place. Explore our Compliance Center.
Analytics
English French
English French

Can I measure traffic sources on mobile apps?

Not automatically, but you can send the source yourself. A mobile app can't see where a visitor came from, so an app open is attributed to Direct traffic unless you provide attribution data. If you can retrieve the origin on your side, the SDK lets you send it.

Apps are separate programs that can't share information with each other, even on the same device. A browser, by contrast, is a single program, so it can easily read the previous page, which gives Piano Analytics the referrer URL. An app, however, is opened from another app (the Google app, a social app, an email client) or manually. When the first screen loads, the SDK can't tell where the visitor came from.

Option

Use it when

What you send

Referrer (previous_url)

You can retrieve the URL or identifier that opened the app, for example through a deep link

The origin URL, in the first event of the visit

Campaign tracker

You control the link, for example in ads, social media, push notifications or email campaigns

src_medium and src_campaign, in the first event of the visit

Send a referrer

If your app can retrieve the URL or identifier that opened it, for example through a deep link (Universal Links on iOS or App Links on Android), pass it in the previous_url property of the first event of the visit. This is usually the first page.display.

pa.sendEvent('page.display', {
  page: 'page name',
  previous_url: 'https://www.referrerSite.com'
});

This has some limits:

  • Not automatic: unlike a browser referrer, the operating system doesn't provide the previous page in most app-to-app navigation.

  • SEO deep links: these generally don't include a referrer. For example, when a user taps a Google Search result that opens your app through a deep link, the app typically doesn't receive the "came from Google" information. Unless you capture and forward the origin URL yourself, Piano Analytics can't rebuild the SEO source, and the visit appears as Direct traffic.

  • Web to app: if a user first lands on a tracked web page that redirects to the app, the web visit can be attributed, for example to Search engines. The app open is a new context, so it's a new visit in the app, often Direct trafic, unless you pass previous_url or campaign parameters into the app.

Use a campaign tracker

A campaign tracker gives you the source of links that you control, such as ads, social media, push notifications or email campaigns. To classify a visit as marketing, campaign information must be in the first event of the visit. At a minimum, fill in these properties:

  • src_medium

  • src_campaign

pa.sendEvent(new Event("page.display", new HashMap<String, Object>() {{
  put("page", "Page name");
  put("src_medium", "email");
  put("src_campaign", "launching");
  put("src_creation", "promotion");
  put("src_myCustomProperty", "myCustomValue");
}}));

Check out our developers documentation on Mobile marketing campaigns.

Campaign tracking doesn't give you the source of links you don't control, such as a search engine results page. To get it, you need a mechanism that adds campaign parameters, or captures the origin, before it opens the app.

App store attribution

To know where an app install came from, rather than where an in-app visit came from, the answer depends on the store:

  • iOS App Store: Apple doesn't provide the install origin to the app. Use Apple's own statistics for download attribution.

  • Google Play Store (Android): the Play Store has an install referrer mechanism. It can pass campaign or deep link information and make it available at first launch. If you capture this value, you can send it to Piano Analytics with src_* properties (marketing) or previous_url (referrer), depending on your attribution model.

If you use AppsFlyer for mobile attribution, the PA Connect AppsFlyer integration sends the marketing source of your installs and re-engagements to Piano Analytics. You can then analyze them with the app.install, app.reengage and app.reattribute events and the src_ properties, without capturing the install referrer yourself. See AppsFlyer.



















To better understand source detection on mobile apps, a key point must be taken into account: apps are individual and distinct programs. This means they cannot share information, even if they’re being used on the same device.

By contrast, web navigation is usually restricted to a single browser. Since only one program is used, it is easy to gather information on previous pages, such as the referrer URL.

Accessing an app is necessarily done via another app (Google app, social app, email client, etc.) or manually. As such, when the first screen is loaded, the SDK has no way of ascertaining where a visitor comes from—i.e., no way of ascertaining the source of the visit. In practice, this means an app open is typically attributed as Direct unless you explicitly provide attribution data.

That said, the SDK does enable you to push this information if you are able to gather it on your end.

Option 1: Send a referrer using previous_url (organic-style attribution)

If your application can retrieve the URL (or identifier) that opened the app (for example via deep links such as Universal Links on iOS or App Links on Android), you can pass it to the first event of the visit (typically the first page.display) using the previous_url property.

Example:

pa.sendEvent('page.display', {
  page: 'page name',
  previous_url: 'https://www.referrerSite.com'
});

Notes and limitations

  • This is not automatically available on mobile. Unlike a browser referrer, the “previous page” is not provided by the operating system in most app-to-app navigation scenarios.

  • SEO deep links generally do not include a referrer. For example, when a user taps a Google Search result that opens your app directly via a deep link, the app typically does not receive the “came from Google” information. Without your own mechanism to capture and forward the originating URL, Piano cannot reconstruct the SEO source and the visit will appear as Direct/Unknown.

  • If the user first lands on a tracked web page and that page redirects to the app, the web visit can be attributed (e.g., Search Engines), but the app open is a new context and will still be treated as a new visit in the app—often Direct—unless you pass previous_url or campaign parameters into the app.

You can also use a campaign tracker. This will enable you to obtain the source for links you have control over, such as for ads, social media, push notifications, or email campaigns.

To classify a visit as marketing-driven, you must ensure campaign information is present in the first event of the visit. At a minimum, populate:

  • src_medium

  • src_campaign

Example:

pa.sendEvent(new Event("page.display", new HashMap<String, Object>() {{
  put("page", "Page name");
  put("src_medium", "email");
  put("src_campaign", "launching");
  put("src_creation", "promotion");
  put("src_myCustomProperty", "myCustomValue");
}}));

What this does not solve

Campaign tracking does not give you the source of visits from links you have no control over, such as a search engine results page (SERP), unless you have an intermediate mechanism that adds campaign parameters or otherwise captures the origin before opening the app.

App store attribution (download origin) considerations

If your use case is to identify where the app install came from (as opposed to where an in-app visit came from), be aware:

  • iOS App Store: Apple does not provide referrer information to the app for install origin. Use Apple’s own statistics for download attribution.

  • Google Play Store (Android): The Play Store supports an install referrer mechanism, which can be used to pass campaign/deeplink information and make it available at first launch. If you capture this value, you can then send it to Piano using src_* properties (marketing) or previous_url (referrer-style), depending on your attribution model.

Last updated: