AMP Web Push Setup
AMP Web Push Setup
This guide will walk you through setting up web push notifications for AMP (Accelerated Mobile Pages) using HoodEngage. AMP web push allows you to engage users with notifications even after they’ve left your AMP pages.
Overview
AMP web push notifications work by:
- Allowing users to subscribe to notifications from AMP pages
- Storing subscription data on Ocamba server
- Sending notifications through Ocamba platform
- Displaying notifications on users’ devices
Prerequisites
- HoodEngage account with API access
- HTTPS-enabled website
- AMP pages already implemented
Step 1: Include AMP Web Push Component
Add the amp-web-push
script to your AMP page’s <head>
section:
<script async custom-element="amp-web-push" src="https://cdn.ampproject.org/v0/amp-web-push-0.1.js"></script>
Step 2: Download Required Files from HoodEngage
HoodEngage provides all the necessary files for AMP web push. Download these files from your HoodEngage dashboard:
helper-frame.html
- Helper iframe for communicationpermission-dialog.html
- Permission dialog interfaceservice-worker.js
- Service worker for handling push events
Upload these files to your server’s root directory or a dedicated folder (e.g., /amp-webpush/
).
Step 3: Configure AMP Web Push Element
Add the amp-web-push
element to your AMP page body:
<amp-web-push
layout="nodisplay"
helper-iframe-url="https://yourdomain.com/helper-frame.html"
permission-dialog-url="https://yourdomain.com/permission-dialog.html"
service-worker-url="https://yourdomain.com/service-worker.js"
></amp-web-push>
Note: Replace
https://yourdomain.com
with your actual domain where you’ve uploaded the HoodEngage files.
Step 4: Add Subscription Widgets
Add subscription and unsubscription widgets to your AMP pages:
<!-- Subscription Widget (shown when user is not subscribed) -->
<amp-web-push-widget
visibility="unsubscribed"
layout="fixed"
width="250"
height="60"
data-amp-bind-hidden="subscribed"
>
<button on="tap:amp-web-push.subscribe" class="subscribe-btn">
🔔 Subscribe to Updates
</button>
</amp-web-push-widget>
<!-- Unsubscription Widget (shown when user is subscribed) -->
<amp-web-push-widget
visibility="subscribed"
layout="fixed"
width="250"
height="60"
data-amp-bind-hidden="!subscribed"
>
<button on="tap:amp-web-push.unsubscribe" class="unsubscribe-btn">
🔕 Unsubscribe
</button>
</amp-web-push-widget>
Custom Styling
Add custom CSS for your widgets:
<style amp-custom>
.subscribe-btn, .unsubscribe-btn {
background: #007bff;
color: white;
border: none;
padding: 12px 20px;
border-radius: 6px;
font-size: 14px;
font-weight: 500;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
transition: background-color 0.2s;
}
.subscribe-btn:hover {
background: #0056b3;
}
.unsubscribe-btn {
background: #6c757d;
}
.unsubscribe-btn:hover {
background: #545b62;
}
</style>
Step 5: HoodEngage Configuration
Dashboard Setup
- Log into your HoodEngage dashboard
- Navigate to AMP Web Push settings
- Configure your domain where the files are hosted
- Set up notification templates for different content types
- Configure targeting rules for your audience
API Integration
HoodEngage handles all server-side processing automatically. The provided service worker and helper files are pre-configured to work with HoodEngage’s infrastructure.
Step 6: Testing
Test Subscription Flow
- Load your AMP page in a supported browser
- Click the subscribe button - you should see the permission dialog
- Allow notifications when prompted by the browser
- Verify subscription is stored in your database
- Test unsubscription by clicking the unsubscribe button
Test Notifications
- Send a test notification from your HoodEngage dashboard
- Verify notification appears on the user’s device
- Test notification click to ensure it opens the correct URL
- Test notification dismissal and tracking
Verify HoodEngage Integration
- Check subscription data is being stored in HoodEngage
- Verify notification delivery through HoodEngage analytics
- Test different notification types (text, rich media, etc.)
- Monitor performance metrics in the dashboard
Troubleshooting
Common Issues
Notifications not appearing:
- Verify HTTPS is enabled
- Check service worker registration
- Ensure notification permissions are granted
- Verify HoodEngage files are properly uploaded and accessible
Subscription not working:
- Check browser console for errors
- Verify helper iframe and permission dialog URLs are accessible
- Ensure HoodEngage files are correctly configured
- Check HoodEngage dashboard for subscription data
AMP validation errors:
- Ensure all required attributes are present
- Verify script sources are from CDN
- Check for custom CSS compliance
- Validate HTML structure
Debug Mode
The HoodEngage service worker includes built-in debug logging. Enable it by setting the debug flag in your HoodEngage dashboard settings.
Best Practices
User Experience
- Don’t prompt immediately - wait for user engagement
- Provide clear value proposition - explain why they should subscribe
- Make unsubscribing easy - always provide an unsubscribe option
- Respect user preferences - don’t spam with notifications
Technical
- Use HTTPS - required for web push
- Handle errors gracefully - provide fallbacks for unsupported browsers
- Test across devices - ensure compatibility
- Monitor performance - use HoodEngage analytics to track subscription rates and engagement
Content Strategy
- Personalize notifications - use HoodEngage targeting features for relevant content
- Time notifications appropriately - use HoodEngage scheduling features
- A/B test messaging - use HoodEngage’s built-in A/B testing tools
- Track engagement metrics - monitor click-through rates in HoodEngage dashboard
Security Considerations
- HoodEngage handles security - all subscription data is validated and secured
- Use HTTPS everywhere - required for web push functionality
- Trust HoodEngage infrastructure - all server-side processing is handled securely
- Monitor dashboard access - ensure only authorized users can send notifications
Browser Support
AMP web push is supported in:
- Chrome 42+
- Firefox 44+
- Safari 16+
- Edge 17+
Note: Some features may have limited support in older browsers.
Next Steps
After completing the setup:
- Configure notification campaigns in HoodEngage dashboard
- Set up analytics tracking for notification performance
- Create notification templates for different content types
- Implement A/B testing for notification content using HoodEngage tools
- Monitor and optimize based on user engagement data from HoodEngage analytics
For more advanced features and customization options, refer to the HoodEngage API documentation and AMP web push documentation.
HoodEngage Benefits
- No server-side coding required - HoodEngage handles all backend processing
- Pre-configured files - Download and deploy ready-to-use components
- Built-in analytics - Track performance and engagement metrics
- Advanced targeting - Use HoodEngage’s sophisticated audience segmentation
- A/B testing tools - Optimize notification content and timing
- Scalable infrastructure - Handle millions of notifications reliably