What’s new in Apphud: Refund Requests Win Back Solution, Web-to-App Match Quality, Integration Improvements, and SDK UpdatesLet’s see
Apphud
Why Apphud?PricingContact
Ren
Ren
May 23, 2024
7 min read

How to Implement Subscriptions in Your Android App

In this article, you will learn how to create, implement, configure, and sell in-app subscriptions in your Android app using Apphud SDK.

How to Implement Subscriptions in Your Android App

Enable Google Billing features in the app

To enable billing-related features in the Google Play Console, you will need to publish your app build to the internal test track. Once you do that, you will be able to create in-app subscriptions.

Add Apphud SDK

Replace {LATEST_VERSION_NUMBER} with the latest version number available on our GitHub Tags page.

The Apphud SDK will automatically install the Google Billing Client dependency.


Set up subscriptions in Google Play Console

After enabling Google Play Billing features for your app, you need to configure subscriptions for the paywalls.

To create a subscription:

  • Go to Google Play Console and navigate to Monetize > Products > Subscriptions page.
  • Click Create Subscription.
  • Enter Product ID and name. For example: com.apphud.sub1.

Tip: It's not recommended to include duration words in the Product ID (e.g., avoid naming it com.app.weekly), since the subscription duration can vary and is controlled by its base plan.

Create a base plan

Starting in May 2022, the new subscription structure was introduced. The new model allows one subscription to have multiple plans and offers, just like Subscription Group on iOS.

The image below illustrates the new structure, where each subscription can have multiple base plans, each with several offers.

Base Plan StructureBase Plan Structure

To set up a base plan, follow these steps:

  • Define the billing period, grace period, and any additional settings such as account holds.
  • Save the base plan.
  • Activate the base plan.
Base Plan in Google Play ConsoleBase Plan in Google Play Console

Create an offer

You can add multiple offers to each base plan, such as free trials or discounts for certain billing cycles.

  • Choose the base plan you want to add the offer to from the drop-down menu and click Add Offer.
  • Enter a unique offer ID. Once activated, this ID cannot be changed or reused.
  • By default, your offer will have the same availability as the base plan. To adjust this, click Manage country/region availability. You can only select regions included in the base plan.
  • Set the eligibility criteria for the offer to specify which customers it applies to New customer acquisition, Upgrade, or Developer determined. Learn more about offer eligibility.
  • For new customer acquisition offers, choose one of the following: Never had this subscription: Available to users who have never subscribed to this subscription.Never had any subscription: Available to users who have never subscribed to any subscription in your app.
  • Never had this subscription: Available to users who have never subscribed to this subscription.
  • Never had any subscription: Available to users who have never subscribed to any subscription in your app.

Add phases to an offer

  • In the offer setup under 'Phases', click Add phase to include free trial or introductory pricing phases. Each offer must have at least one pricing phase.
  • Select the type of pricing phase:
Subscriptions in Google Play ConsoleSubscriptions in Google Play Console

Add subscriptions to Apphud

If you don't have an Apphud account yet, create your free account and add your first app. You'll need to provide the Package Name and Google Service Account Credentials.

Once your account and app are set up, it's time to configure products and paywalls.

The process for setting up subscriptions in Apphud is similar to setting up consumable in-app purchases. Simply provide the Product ID, and Apphud will handle the rest. This includes setting up the product type, pricing, terms, etc., once the first purchases with this Product ID are received.

Apphud Product HubApphud Product Hub

Once the Product IDs are added to the Product Hub -> Products page, it's time to create paywalls.

Go to the Paywalls tab and create your first paywall:

  • Name: This is the name of your paywall. It will be used only in Analytics and the web dashboard.
  • Identifier: This is the string identifier of your paywall. It will be used in your app code.

The final step is to create placements and assign paywalls to them.


Create Placements in Apphud

Apphud PlacementsApphud Placements

A placement is a specific location within a user's journey, such as onboarding, settings, or other key points, where a targeted paywall is intended to be displayed. These placements allow app developers to strategically position their paywalls in various parts of the app. Each placement can contain only one paywall per app user.

Developers can assign a specific user audience for each paywall within a placement. This means you can have different paywall configurations for various regions or user segments. Additionally, you can specify custom JSON for each paywall, providing greater flexibility in how you tailor the paywall experience to different audiences.

The main advantage of placements is the ability to optimize paywall conversion rates through strategic positioning and A/B testing. By experimenting with different paywall setups at each placement, you can continuously improve the effectiveness of your paywalls.


Initialize Apphud SDK

Initialization is simple: use the API Key found in your Apphud project settings.


Make a Purchase

To make a purchase, pass an ApphudProduct model to the purchase method:

The Offer ID Token is optional; if not provided, the first available Offer ID Token of the given base plan will be used. You must also pass your activity instance.

The ApphudProduct object can be retrieved from the products list of the corresponding paywall (ApphudPaywall model). Although using placements is the recommended way to handle paywalls, you can still access the unordered paywalls list using the Apphud.paywallsDidLoadCallback { paywalls, error in } method.

If using placements (recommended), fetch paywalls by fetching placements first:

In the callback, you will receive a list of placements that were set up in the Product Hub.

To display the products of the paywall, first find your placement by its identifier, depending on the current location in the app. For instance, if you need paywall products for onboarding, get the onboarding placement first, then get its paywall. Each placement has only one paywall per user.

Display the products on your paywall based on the product array of the paywall model. Once the user selects a plan (product), initiate a payment with the selected ApphudProduct model.

You can view your transaction data in the Events tab in the Apphud dashboard:

Apphud Events ListApphud Events List

That's it! You can now explore other Apphud features, like A/B Experiments or Integrations.


Benefits of using Apphud SDK compared to a custom solution

  • Remote Paywall and Audience Management: Easily manage your paywalls and target audiences remotely, allowing you to control how paywalls are displayed to each particular user.
  • User-Level Data: Access real-time purchase history for each individual user, enabling detailed insights and personalized user experiences.
  • A/B Testing: Conduct A/B experiments out-of-the-box to test and optimize your paywalls, ensuring you find the most effective pricing strategies.
  • LTV Prediction: Utilize Lifetime Value (LTV) prediction to identify which subscriptions are the most valuable in your app.
  • Advanced Subscription Analytics: Make informed product growth decisions using advanced revenue analytics such as ARPAS (Average Revenue Per Active Subscriber) and Cumulative LTV.
  • Integration with Third-Party Services: Send subscription renewal events to third-party integrations like Facebook, AppsFlyer, Amplitude, Firebase, and more.

Apphud is the easy-to-integrate subscription app infrastructure and analytics platform for scaling your results. Sign up for Apphud today!

Ren
Ren
Co-founder at Apphud
Ex iOS app and game developer. 11 years in the industry since iOS 3. More than 50 apps are in the background with 4 exits. Entrepreneur and traveler.