Guide

Analytics architecture

How @prc/analytics wires providers, settings, REST, and Abilities.

Bootstrap

Bootstrap instantiates a Loader, then attaches Providers, Ability, Rest_API, and Settings.

Bootstrap
├── Providers
│   ├── Parsely            (lazy; API v2 + CLI)
│   ├── Google_Analytics   (lazy; GA4 Data API + CLI)
│   ├── Tracking_Pixels    (Meta, Pinterest, LinkedIn, Reddit)
│   └── Civis              (API key auth + CSV exports)
├── Ability                (analyze-post, analyze-topic)
├── Rest_API               (query-by-url, query)
└── Settings               (Settings → Analytics)

Source: includes/class-bootstrap.php, includes/providers/.

Providers

ProviderRole
Parse.lyPost detail, per-URL referrers (referrers/post/detail), and top-posts analytics via API v2
Google Analytics 4Server-side runReport with JWT service account
Tracking pixelsConsent-gated client scripts when constants are set
CivisPaginated CSV exports for Civis “Import from URL”

Parse.ly and GA4 load lazily on first use. CLI commands register at bootstrap (wp prc analytics parsely, wp prc analytics ga).

Files such as class-semrush.php and class-data-mart.php exist under includes/providers/ but are not constructed by Providers. Salesforce beacon loading uses filters prc_analytics_salesforce_script_url and prc_analytics_salesforce_dataset (see class-predictive-response.php).

Secrets and constants

All secrets belong in vip-config/keys-and-tokens.php (or VIP Platform Secrets), not in the repo.

Constant / filePurpose
PRC_PLATFORM_PARSELY_API_KEY, PRC_PLATFORM_PARSELY_SECRETParse.ly API
PRC_PLATFORM_GA4_PROPERTY_IDGA4 property
private/ga4-service-account.jsonWPCOM_VIP_PRIVATE_DIRGA4 service account (file-only)
PRC_PLATFORM_*_PIXEL_ID / partner IDsClient pixels
PRC_PLATFORM_GOOGLE_GTAG_IDClient-side gtag only (not in Settings pixel toggles)

Civis API keys are stored in prc_analytics_settings, not as PHP constants.

Dependencies

  • Upstream: prc-platform-core / prc-scripts, prc-privacy-consent + wp-consent-api (pixels), prc-staff-bylines (REST bylines), Firebase (Civis users export)
  • Downstream: Civis Import-from-URL jobs, MCP / Abilities consumers

Was this helpful?