Extending Web Push Notifications for Sitecore
Next week at Sitecore Symposium you can tune in it to my on demand presentation for an overview of the Web Push Notifications for Sitecore module that's been published on Github. This module makes it easy to collect subscriptions and use them to send Notifications to subscribers using Sitecore's Marketing Automation. While you can install this module and use it out of the box to create some engaging campaigns, there are several places where I could see where extending the module would have clear benefits.
Capturing Viewed Analytics
When you send push notifications to visitors, a JavaScript service worker receives the message and displays the notification. If you really want to know if the messages was delivered and shown to the user, this is the perfect place to add additional code. If you're using "Clientside Analytics for Sitecore," you could use the provided JavaScript library to track it as an Interaction, otherwise you'll need to roll your own endpoint to properly track the push notification as a View.
It's probably also worthwhile to capture the notification in Google Analytics. Integrating with GA can be a little tricky, but leveraging this analytics library and integrating into your service worker seem to be a good solution.
Don't forget to tag any CTA's with Sitecore Campaign tracking parameters and GA UTM tracking parameters. This will make sure you have the full picture of sends (Marketing Automation Report View), Views and Click throughs to really understand how you’re campaigns are truly performing. And if desired, you can modify your service worker to track when visitors unsubscribe.
Controlling & Optimizing Notifications
When notifications are sent to subscribers, all the content of the notification is included in the message. This was the path of least resistance, but not the only way it could have worked. There is actually a great opportunity to modify how this works that will make Web Push Notifications even more effective. If instead of sending the message details to subscribers, it simply sent the Guid of a Sitecore Item that stored those message details, the Service worker could be modified to make a request to pull down the details of that Sitecore Item to provide the message details.
And if that was just a normal web request, the JSON that represented the notification could be produced using a custom layout and rendering that outputted the JSON in the appropriate format. The advantage of doing it that way is that you would then be able to Add Personalization rules or even AB test your Notification messages. It would probably also automatically handle analytics tracking as an interaction given that it was just a normal page request. This would make messages even more powerful.
You may wonder why I didn't build it that way in the first place. Besides being much more complicated, I needed to think through the UX required to Manage Sitecore Items from the Marketing Automation Activity. A simple text field with a Guid could have worked, it wouldn't have been very friendly for marketers. Building a custom UI for it is possible, but requires thinking through a number of issues. It also would make it confusing to know what messages were actually sent to visitors, so I went with the path of least resistance.
Adding Action Buttons
You may have noticed that while most supported notification fields are available in the custom Marketing Automation Activity, I did not include support for Custom Actions. Custom actions enable you to add CTA buttons at the bottom of the notification that can send a user to multiple locations with a single notification.
I left it out of my initial implementation because they aren't as widely supported as other notification attributes and it would require adding additional Text and CTA fields that would look pretty clunky. If you're moving toward storing notification details in a Sitecore Item, having additional fields to support these where desired would be easy enough.
Preferences Center for Web Notifications
In my demoes and examples, I recommend adding your subscribers to Lists, so that you can target them with blast notifications later. You can either segment those lists or add subscribers to multiple lists so you can better control the messages that you send to them. If you go down that route, you may want to consider how to allow visitors to unsubscribe to specific lists as opposed to unsubscribing to all notifications in the browser which will disable you're ability to send them any messages at all. EXM has a preferences center which may be able to be used to manage similar preferences for web push campaigns.
These are a few of my immediate ideas for how you can make web push notifications and Sitecore even more powerful. Checkout my on demand presentation at Sitecore Symposium next week, Install one of the releases for Sitecore 10 or Sitecore 9.3 or just get the source code on github and start extending it.
Let me know what you think or if you have any other ideas on how to make it better. Would be happy to accept any Pull Requests too!