OneSignal Help & Documentation

Welcome to the OneSignal New IA developer hub. You'll find comprehensive guides and documentation to help you start working with OneSignal New IA as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    Discussions

Links, Deep-links and URLs

Concepts - Linking to internal and external URIs

When subscribers click your notifications, you can link them to a specific url or deep link to a page in the app. OneSignal provides a few options for handling links within your mobile app or website.

Launch Url

When Sending Push Messages, use the OneSignal dashboard's "Launch URL" or the API's url parameter to place a URL that can open a webpage and/or deep link within your app.

Protocol

Websites

iOS Mobile Apps

Android Mobile Apps

http:// or https://

Required for Web Push. Will link the user to the URL upon push click.

Will open In-app Browser or default Browser depending if kOSSettingsKeyInAppLaunchURL set to true or false.

Handle Programmatically within click handler. Example below.

Examples:
x://
schema://
link://

Not available for Web Push.

Handle Programmatically within click handler. Example below.

Handle Programmatically within click handler. Example below.

If you have a Website and Mobile App, you can set Different URL for web/app with the web_url and app_url parameters on the dashboard or API. Then input the http:// or https:// Web URL and deep-link:// protocol for mobile apps.

Handle Launch URL on Mobile

Within your Mobile App's OneSignal SDK Notification Opened Handler you can capture the result.notification.payload.launchURL and process the deep link.

class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
  @Override
  public void notificationOpened(OSNotificationOpenResult result) {
    Log.i("OSNotificationPayload", "result.notification.payload.toJSONObject().toString(): " + result.notification.payload.toJSONObject().toString());
    // Capture Launch URL (App URL) here
    String launchUrl = result.notification.payload.launchURL;
    Log.i("OneSignalExample", "launchUrl set with value: " + launchUrl);
    if (launchUrl != null) {
      // The following can be used to open an Activity of your choice.
      // Replace - getApplicationContext() - with any Android Context.
      // Replace - YOURACTIVITY.class with your activity to deep link
      Intent intent = new Intent(getApplicationContext(), YOURACTIVITY.class);
      intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
      intent.putExtra("openURL", launchUrl);
      Log.i("OneSignalExample", "openURL = " + launchUrl);
      startActivity(intent);
    }
  }
}
let notificationOpenedBlock: OSHandleNotificationActionBlock = { result in
  let payload: OSNotificationPayload? = result?.notification.payload
  print("appUrl: ", payload.launchURL ?? "No Launch Url")
  if let appUrl = payload?.launchURL {
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    // if your app is using the navbar controller within the tabbar controller
    if let postDetailVC = storyboard.instantiateViewController(withIdentifier: "PostDetailViewController") as? PostDetailViewController,
        let tabBarController = self.window?.rootViewController as? UITabBarController,
        let navController = tabBarController.selectedViewController as? UINavigationController {
            navController.popViewController(animated: false)
            navController.pushViewController(postDetailVC, animated: true)
    }
  }
}

UTM Parameters

UTM parameters are query parameters added to URLs to measure the effectiveness of a marketing campaign. OneSignal allows you to automatically set source, medium, and campaign parameters for your push notification's sent from the OneSignal Dashboard using the Launch URL / App URL and Action Button URLs.

🚧

UTM Parameter Limitations

Emails, Automated Messages, and API requests do not include UTM parameters. You will need to add them within the Template or API request directly.

If you are using the OneSignal WordPress Plugin, you can add UTM parameters within the Plugin Settings towards the bottom within the UTM Tracking Settings.

Enable UTM parameters in Settings > Messaging > Turn on automated UTM tagging

You can edit these values to suit your requirements. Default UTM parameters are as follows:

  • Source = onesignal
  • Medium = push
  • Campaign = {{ sendDate }}-{{ title }}

sendDate: Sent At date from the Delivery → Sent Messages statistics
title: First 15 chars (a-z, A-Z, 0-9, underscore, hyphen) of the message title

Note: Message variables sendDate and title are for the campaign parameter only.

Example URL with UTM parameters appended from the settings:
https: //test. com?utm_source=onesignal&utm_medium=push&utm_campaign=2020-06-03-sale-today

Jump to UTM FAQ for more answers to frequently asked questions.


Deep Linking With Additional Data

Deep Linking with Additional Data should be used if you only have Mobile Apps setup with OneSignal (no website) and do not want to open the URL within an in-app webview.

If you have both web and mobile app subscribers, you can also deep link following the above Launch URL section.

Using Additional Data or the API data parameter, you can pass some data into the notification and handle it programmatically within the SDK Notification Opened Handler and the OSNotificationPayload object.

For example, if you set customkey : profile as the data, you can detect this key: value pair in your app from result.notification.payload.additionalData and send the user to the "Profile" page or any page you decide to use for the value.

class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler {
  // This fires when a notification is opened by tapping on it.
  @Override
  public void notificationOpened(OSNotificationOpenResult result) {
    Log.i("OSNotificationPayload", "result.notification.payload.toJSONObject().toString(): " + result.notification.payload.toJSONObject().toString());
    JSONObject data = result.notification.payload.additionalData;
    String customKey;
    
    if (data != null) {
      customKey = data.optString("customkey", null);
      if (customKey != null) {
        // The following can be used to open an Activity of your choice.
        // Replace - getApplicationContext() - with any Android Context.
        // Replace - YOURACTIVITY.class with your activity to deep link
        Intent intent = new Intent(getApplicationContext(), YOURACTIVITY.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra("openURL", customkey);
        Log.i("OneSignalExample", "openURL = " + customkey);
        startActivity(intent);
      }
    }
  }
}
let notificationOpenedBlock: OSHandleNotificationActionBlock = { result in
    // This block gets called when the user reacts to a notification received
    if let additionalData = result!.notification.payload!.additionalData {
        print("additionalData: ", additionalData)
        print(additionalData["postId"] as! String)

        if let postId = additionalData["postId"] as? String {
            let storyboard = UIStoryboard(name: "Main", bundle: nil)
            if  let postDetailVC = storyboard.instantiateViewController(withIdentifier: "PostDetailViewController") as? PostDetailViewController,
                let tabBarController = self.window?.rootViewController as? UITabBarController,
                let navController = tabBarController.selectedViewController as? UINavigationController {
                    let dataModel = PostDataModel()
                    dataModel.postId = postId
                    postDetailVC.dataModel = dataModel
                    navController.popViewController(animated: false)
                    navController.pushViewController(postDetailVC, animated: true)
            }
        }
    }
}
^(OSNotificationOpenedResult *result) {
   OSNotificationPayload* payload = result.notification.payload;
   //Check if customkey is available in payload and go to that page
}
onOpened(openResult) {
    console.log('Data: ', openResult.notification.payload.additionalData);
    // Use this to check for customkey and go to that page
}
private static void HandleNotificationOpened(OSNotificationOpenedResult result) {
  OSNotificationPayload payload = result.notification.payload;
  Dictionary<string, object> additionalData = payload.additionalData;

  print("GameControllerExample:HandleNotificationOpened: " + message);
  extraMessage = "Notification opened with text: " + message;

  if (additionalData != null) {
    if (additionalData.ContainsKey("discount")) {
      extraMessage = (string)additionalData["discount"];
      // Take user to your store.
    }
  }
}

📘

Github Examples

Please see our Github Examples for more:

Operating System Level Deep Linking

If deep linking into another app, then you should send the deep link as part of the regular URL field of the posted notification. See iOS's documentation on UniversalLinks and Android Deep Linking.

Note - Support for 3rd party SDKs such as Branch is limited. Sending a deep link as Example: @{ @"branch" : @"https://[branchsubdomain]/ALMc/e03OVEJLUq" } may lead to undefined behavior.

Deep link into the app store

Android - You can enter the store link as the launch URL. More details on this here: https://developer.android.com/distribute/marketing-tools/linking-to-google-play.html

iOS

  1. you can link directly to your app using a launch url like this:
    itms-apps://apps.apple.com/us/app/YOUR_APP_NAME/idYOUR_APPLE_APP_ID or to write a review: itms-apps://apps.apple.com/us/app/YOUR_APP_NAME/idYOUR_APPLE_APP_ID?action=write-review
  2. you can use Universal Links: https://developer.apple.com/ios/universal-links/
  3. you can use the SKStoreProductViewController in the OneSignal click event handler: https://developer.apple.com/reference/storekit/skstoreproductviewcontroller

More details on this stackoverflow here: http://stackoverflow.com/questions/433907/how-to-link-to-apps-on-the-app-store

Dynamic URLs

Using variables to write your URL is not currently supported. Use these alternate methods instead:

  1. With tags, you can add Message Personalization to the Launch URL.

  2. Deliver notifications individually to each user through our REST API, with a different URL for each. See Transactional Messages.

  3. Provide a notificationOpenedCallback. In that callback, fetch the user's OneSignal details using getIdsAvailable or getTags and redirect them to the page of your choice.

No Linking

Currently on mobile apps, anytime the user clicks the push it will open the app.

Web Push: If you do not want to link to any page or url, you can add ?_osp=do_not_open to the end of a URL like this https://yoursite.com/page?_osp=do_not_open as the launch url, this will prevent the push from going to any url upon click and will just dismiss the push.


FAQ

How are UTM parameters appended to my URLs?

With UTM Tagging enabled in app settings, you should enter the launch URLs without the UTM parameters as these will be appended automatically.

If you add custom UTMs with this feature enabled, then the custom UTMs will override the default.

Can I use non-English characters in the UTM parameters?

Yes! We don’t validate the accuracy of a URL. If there are characters other than a-z, A-Z, 0-9, underscores, or hyphen entered in a URL or UTM parameters, then please make sure the URL works before sending the notification.

How to use UTM parameters?

Google Analytics, for example, uses links with UTM parameters to provide insights into your campaigns and users. These are a few common ways to use Google Analytics to understand your traffic, user behavior, and conversion data:

  • Understand Your Campaigns: Replicate the successful campaigns and improve the underperforming ones.
    On Google Analytics, navigate to Acquisition > Campaigns > All Campaigns

    • Compare metrics across different campaigns, such as users, sessions, bounce rates, and goal conversions. If you’ve used the same UTM campaign tag for different sources or mediums, you can click into that campaign and compare the performance across these different channels (source/medium).
  • Understand Your Audiences: Identify the successful user segments and improve your target audience for future campaigns.
    On Google Analytics, navigate to Audience > Demographics | Interests | Geo | Mobile

    • Add Campaign as a secondary dimension to Audience reports. Compare campaign performance across demographic segments (Age, Gender, Location, Devices) or interests (Affinity Categories, In-Market Segments).
  • Understand Your Channels: Optimize your marketing channels.
    On Google Analytics, navigate to Acquisition > All Traffic > Source/Medium

    • Compare the performance of push as a channel with your other channels, such as email or paid ad campaigns.

For more advanced analysis, filter your data by date ranges and audience segments. Add a secondary dimension for deeper insight. Set up goals, events, and custom data to track conversions.

Updated 23 days ago



Links, Deep-links and URLs


Concepts - Linking to internal and external URIs

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.