Phoenix Documentation
Phoenix ProductionPhoenix PreviewContentful
Primary version
Primary version
  • 🔥Phoenix 🔥
  • Installation + Usage
    • Prerequisites
    • Installation
    • Usage
  • Development
    • Architecture
      • Heroku
    • Content Types
      • Action Stats Block
      • Campaign
      • Content Block
      • Cause Page
      • Company Page
      • Current Club Block
      • Current School Block
      • Embed
      • External Link
      • Landing Page
      • Link Action
      • Metadata
      • Page
      • Photo Submission Action
      • Selection Submission Action
      • Share Action
      • Signup Referrals Block
      • Social Drive Action
      • Voter Registration Action
      • Voter Registration Drive Action
      • Voter Registration Marketing Page
      • Voter Registration Referrals Block
    • Features
      • Affiliate Opt In
      • Affiliate Scholarship Block
      • Analytics Waypoint
      • Delayed Element
      • Dismissable Element
      • Stat Card
      • General Buttons
      • Groups
      • Paginated Campaign Gallery
      • Popover Dispatcher
      • Refer A Friend
      • Referrals Gallery
      • Sitewide Banner
      • Sixpack A/B Testing
        • Code Tests
        • Contentful Tests
        • Testing Tips
      • Tooltip
      • Traffic Distribution
      • Volunteer Credits
      • Voter Registration
      • Zendesk Form
    • Contentful
      • Workflow
      • Content Management API Scripts
    • Helpers
  • Phoenix API
    • v2
      • Campaigns Resource
      • Posts Resource
      • Zendesk Endpoint
  • Data + Performance
    • Monitoring
    • Analytics
    • Logging
  • Contributing Instructions
    • Edit This Documentation
    • Glossary
Powered by GitBook
On this page
  • Overview
  • Usage Instructions
  • Under The Hood
  1. Development
  2. Features

Analytics Waypoint

PreviousAffiliate Scholarship BlockNextDelayed Element

Last updated 5 years ago

Overview

The AnalyticsWaypoint component provides a way to track user impressions of any feature or block in Phoenix. It tracks if & when the component enters the , and triggers an analytics event to track the impression.

Usage Instructions

Simply render the AnalyticsWaypoint component from the start and and end of the component you'd like to track with the following props:

  • name: Used as the label and added as context.name for the event

  • context (optional): Used as the context for the event

So if we wanted to track users impression of the ContentBlock component's start & end:

const ContentBlock = ({ id }) => (
  <>
    <AnalyticsWaypoint
      name="content_block-top"
      context={{blockId: id}}
    />

    {<!-- component specific JSX -->}

    <AnalyticsWaypoint
      name="content_block-bottom"
      context={{blockId: id}}
  <>
);

Under The Hood

It triggers an analytics event with the following properties:

metadata: {
  verb: 'reached',
  noun: 'waypoint',
  target: 'waypoint',
  category: 'waypoint',
  label: [name prop],
},
context: {
  ...context,
  name: [name prop],
},

The component makes use of the NPM package which utilizes the to detect when the element intersects with the viewport.

viewport
react-intersection-observer
Intersection Observer API