Overview
The analytics integration automatically tracks key user interactions including page views, story completion, link clicks, audio interactions, and page attachment engagement.Configuration
Setting Up Google Analytics
- Navigate to Stories > Settings > Analytics in your WordPress admin
- Enter your Google Analytics tracking ID (format:
UA-XXXXX-YorG-XXXXXXXXXX) - Save your settings
The plugin uses
<amp-story-auto-analytics> by default for automatic event tracking. Legacy <amp-analytics> mode is also available for backward compatibility.Tracked Events
The plugin automatically tracks the following story interactions:Story Progress Events
Story Progress Events
- story_progress: Fired when each story page becomes visible
- story_complete: Fired when the last page is shown (completion rate)
- Event data includes story title, page index, and progress percentage
User Interaction Events
User Interaction Events
- story_focus: User clicks an element that opens a tooltip (links, embedded content)
- story_click_through: User clicks through on a tooltip or link
- story_open: User opens a drawer or dialog (e.g., page attachments)
- story_close: User closes a drawer or dialog
Audio Events
Audio Events
- story_audio_muted: User mutes the story audio
- story_audio_unmuted: User unmutes the story audio
Page Attachment Events
Page Attachment Events
- story_page_attachment_enter: User opens a page attachment
- story_page_attachment_exit: User dismisses a page attachment
Implementation Details
The analytics tracking is implemented inincludes/Analytics.php:99-235 and uses two modes:
Auto Analytics (Default)
The modern approach using<amp-story-auto-analytics>:
Legacy Analytics
For advanced customization, you can enable legacy mode which uses<amp-analytics> with a custom configuration:
Custom Analytics Configuration
You can customize the analytics configuration using WordPress filters:Filter Analytics Configuration
Variable Substitutions
When configuring custom analytics events, you can use AMP variable substitutions:${title}- Story title${storyPageIndex}- Current page index${storyPageCount}- Total number of pages${storyProgress}- Progress percentage (0-100)${canonicalUrl}- Story URL
Privacy Considerations
The analytics integration respects user privacy and complies with GDPR requirements. Make sure to include Google Analytics in your privacy policy and cookie consent mechanisms.
Troubleshooting
Analytics not showing data
Analytics not showing data
- Verify your tracking ID is correct in Stories > Settings
- Check that you’re not using the plugin’s internal tracking ID
- Allow 24-48 hours for data to appear in Google Analytics
- Use the Google Analytics Debugger Chrome extension to verify events are firing
Events not tracking correctly
Events not tracking correctly
- Open your browser’s developer console and check for errors
- Verify the story is using AMP validation
- Test with legacy analytics mode if auto-analytics isn’t working
- Check that third-party analytics plugins aren’t interfering