Articles › Pushpad, Targeting Users

How to send a notification only to a random subset of users

  • # targeting

What if you want to send a web push notification only to 10% of your users? This can be useful for example for testing and for measuring CTR for that notification before sending it to all your users. There are many ways to achieve that, but in this tutorial we will show a simple method with tags.

When a browser subscribes to your notifications assign it randomly to a group (group1, group2, group3... group10). If you use the Pushpad Javascript SDK you can use a code like this:

pushpad('status', function (isSubscribed) {
  // if the browser is not subscribed to notifications...
  if (!isSubscribed) {
    // subscribe and assign the browser to a group
    var groupId = Math.floor((Math.random() * 10) + 1);
    pushpad('subscribe', function () {}, {tags: ["group" + groupId]});

Then you can reach only 10% of your users when you send a notification. When you define your audience use this filter on tags:


Or if you want to reach 20% of your users use this:

group1 || group2

Finally you can also send the notification to all the other users that you haven't reached initially (e.g. 90%) by using this filter on tags: