Skip to content

Firebase Cloud Messaging Campaigns — Scheduling and A/B Testing Push Notifications

DodaTech Updated 2026-06-28 4 min read

In this tutorial, you will learn about Firebase Cloud Messaging Campaigns. We cover key concepts, practical examples, and best practices to help you master this topic.

Firebase Cloud Messaging campaigns enable scheduling push notifications, A/B testing different message variants, targeting specific audiences, and measuring notification performance through analytics integration.

What You'll Learn

  • Creating scheduled notification campaigns
  • Setting up A/B tests for notifications
  • Analyzing campaign performance

Why It Matters

Scheduled campaigns engage users at optimal times. A/B testing improves notification effectiveness. DodaTech uses campaigns for weekly security digest emails and A/B tests notification timing.

flowchart LR
    A["Campaign Setup"] --> B["Choose audience"]
    A --> C["Create message"]
    A --> D["Schedule delivery"]
    A --> E["A/B test variants"]
    B --> F["Launch campaign"]
    C --> F
    D --> F
    E --> F
    F --> G["Monitor analytics"]
    G --> H["Optimize future campaigns"]

Code Examples

// Programmatic campaign via Admin SDK
const admin = require('firebase-admin');

async function createCampaign() {
  const message = {
    notification: {
      title: 'Weekly Security Report',
      body: 'Your weekly security report is ready'
    },
    topic: 'security-alerts',
    android: { priority: 'high' },
    apns: { payload: { aps: { sound: 'default' } } }
  };

  // Send immediately
  await admin.messaging().send(message);

  // For scheduled campaigns, use Cloud Scheduler
  // Schedule with Cloud Functions
}
// Cloud Function for scheduled notifications
const functions = require('firebase-functions');
const admin = require('firebase-admin');

// Schedule with Cloud Scheduler
exports.scheduledWeeklyDigest = functions.pubsub
  .schedule('0 9 * * 1')  // Every Monday at 9 AM
  .timeZone('America/New_York')
  .onRun(async (context) => {
    const message = {
      notification: {
        title: 'Weekly Digest',
        body: 'Your weekly activity summary is ready'
      },
      topic: 'all-users',
    };

    await admin.messaging().send(message);
    console.log('Weekly digest sent');
  });

// A/B test variant selection
exports.sendABTestNotification = functions.https.onCall(async (data, context) => {
  const variant = Math.random() > 0.5 ? 'A' : 'B';

  const title = variant === 'A'
    ? 'New Features Available'
    : 'Check Out What\'s New';

  const body = variant === 'A'
    ? 'We added 3 new features you will love'
    : 'Explore the latest updates in your dashboard';

  const message = {
    notification: { title, body },
    topic: 'all-users',
    data: { variant, testName: 'feature-announcement' }
  };

  await admin.messaging().send(message);
  return { variant };
});
# Using Firebase Console for campaigns
# Firebase Console > Cloud Messaging > New Campaign
# 1. Select audience (topic, user segment, or all)
# 2. Compose notification
# 3. Schedule delivery time
# 4. Add conversion events for A/B testing
// Track campaign conversions with Analytics
import { logEvent } from 'firebase/analytics';

// When user opens notification
logEvent(analytics, 'notification_open', {
  campaign_name: 'weekly_digest',
  campaign_variant: 'A',
  message_id: 'msg_123'
});

// When user completes target action
logEvent(analytics, 'notification_conversion', {
  campaign_name: 'feature_announcement',
  conversion_type: 'feature_click'
});

Common Mistakes

1. Sending Notifications at Inappropriate Times

Respect user time zones. Use Cloud Scheduler with time zone support.

2. Not Testing A/B Variants Enough

Run A/B tests with sufficient sample size for statistical significance.

3. Ignoring Notification Fatigue

Too many notifications cause users to disable them. Limit campaign frequency.

4. Not Adding Conversion Tracking

Without conversion tracking, you cannot measure campaign effectiveness.

5. Forgetting to Segment Audiences

Targeted campaigns outperform broadcast campaigns. Segment by user behavior.

Practice Questions

  1. How do you schedule a notification campaign?
  2. What is A/B testing for notifications?
  3. How do you track notification conversions?
  4. What is the best time to send push notifications?
  5. How do you segment audiences for campaigns?

Answers:

  1. Use Cloud Scheduler via Cloud Functions or the Firebase Console scheduling feature.
  2. Sending different message variants to measure which performs better.
  3. Log analytics events when users interact with notifications.
  4. Analyze user engagement data. Typically mid-morning on weekdays works best.
  5. By user behavior, preferences, location, or custom audience segments.

Challenge: Plan and execute a notification campaign Strategy. Create weekly scheduled digests, A/B test notification timing and messaging, track conversions with Analytics, and analyze results to optimize future campaigns.

FAQ

Can I schedule campaigns through the Admin SDK?

The Admin SDK supports immediate sends. Use Cloud Scheduler or the Firebase Console for scheduled campaigns.

How many A/B test variants can I create?

Firebase Console supports up to 5 variants per A/B test, including the control group.

How long should I run an A/B test?

Run until you have statistical significance, typically 1-2 weeks depending on audience size.

Can I target specific app versions in campaigns?

Yes. In the Firebase Console, you can target by app version, language, and other user properties.

How do I analyze campaign performance?

Use Firebase Analytics dashboard to view opens, clicks, conversions, and revenue attribution for each campaign.

Mini Project

Plan and execute a notification campaign strategy: create weekly scheduled digests using Cloud Scheduler, implement A/B testing for notification copy and timing, track conversions with Analytics events, and build a campaign performance dashboard.

What's Next

Learn about Firebase Remote Config for feature flags and A/B testing, then explore Firebase Analytics for user behavior tracking.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro