Skip to content

View tracking — the capture pipeline

Every time a logged-in member browses to another member’s profile, the plugin’s capture pipeline runs. It hooks into the_content (only firing when the request resolves to a single user profile via bp_is_user()), checks dedupe rules, respects per-user opt-outs, and inserts a row into {prefix}bp_profile_views.

  1. The member opens a profile.
  2. The pipeline checks bp_profile_views_general_options['save_count_by']:
    • session — dedupes via the user meta bp_profile_views_user_login_session, keyed by login session token, stamped per displayed user per calendar day. Same viewer revisiting the same profile inside the same login session counts once.
    • referer — dedupes via the transient bp_profile_views_referer_transient plus cookies (BP_PROFILE_VIEW_REQUEST_URI and BP_IS_USER). Same viewer revisiting the same profile within 6 hours counts once.
  3. The pipeline reads the visitor’s visitor_setting user meta. If it’s 'no' (the user has opted out), no row is recorded.
  4. Logged-out visitors are recorded with viewer_id = 0. The exclude_logout_user_count option filters those rows out of every aggregate query at read time — they’re stored, but invisible.
  5. Bot User-Agents (Googlebot, Facebot, LinkedInBot, Pingdom, curl, etc.) are filtered out before the row is inserted. New in 1.5.0.
  6. After insert, the action bp_profile_views_after_insert fires with the new row ID.

General tab — capture controls

  • Dedupe strategy — General tab → “How views are counted”.
  • Exclude logged-out viewers — General tab → “Viewer types”.
  • Per-user opt-out — General tab → “Member control” (admin-side); profile Views tab toggle (member-side).

See General tab for the full list and defaults.

The plugin always records every qualifying view in the database. What gets counted in aggregates and shown in the UI depends on your settings:

  • exclude_logout_user_count = yes → logged-out rows (viewer_id = 0) are excluded from counts and the Views tab.
  • A user with visitor_setting = 'no' → their visits are not even recorded going forward.
  • The dedupe strategy controls whether repeated visits create new rows or are skipped.

This means:

  1. The raw row count in {prefix}bp_profile_views is always the count shown anywhere in the UI.
  2. Turning exclude_logout_user_count off later doesn’t backfill — old anonymous rows simply become visible.
  3. Re-enabling tracking for a user who opted out doesn’t recreate visits they made while opted out.

To forward each view to an analytics service or trigger custom logic, hook the action bp_profile_views_after_insert. See Hooks and filters.