Click and Impression Tracking
The Sponsors module automatically counts how many times each sponsor is displayed (impressions) and how many times visitors click a sponsor's logo or "Visit Site" button (clicks). Both counts are stored as post meta on the sponsor post and visible on the sponsor edit screen.
This feature is part of SportsPress Pro.
Meta Keys
Meta Key | Description |
| Total number of times this sponsor has been displayed to a visitor |
| Total number of times a visitor has clicked this sponsor |
Both values are read-only in the admin UI. They appear in the Details sidebar meta box on the sponsor edit screen as plain text fields labelled Impressions and Clicks. The fields are rendered with readonly="readonly" — they cannot be manually edited.
Impression Tracking
Impressions are counted in the sp_set_post_impressions() function. Each time a sponsor template renders, this function is called with the sponsor's post ID. It reads the current sp_impressions meta value, increments it by 1, and writes it back with update_post_meta().
If the meta value does not yet exist for a sponsor, it initialises to 0 before incrementing.
Click Tracking
Clicks are tracked via an AJAX request triggered by JavaScript when a visitor clicks a sponsor's logo or "Visit Site" link. The client-side code sends a POST request to admin-ajax.php with:
action=sp_clickspost_id= the sponsor's post IDnonce= a nonce value (sp_clicks_{post_id})
The server-side handler is SportsPress_Sponsors::sp_clicks(). It verifies the nonce, then calls sp_set_post_clicks() which increments the sp_clicks meta value by 1 using the same pattern as impression tracking.
Excluding Logged-In Users
Two settings under SportsPress → Settings → Sponsors control whether logged-in users' activity is counted:
Impressions — Exclude logged-in users (option ID:
sportspress_exclude_authenticated_sponsor_impressions, default: no) — When enabled,sp_set_post_impressions()returns early ifis_user_logged_in()is true.Clicks — Exclude logged-in users (option ID:
sportspress_exclude_authenticated_sponsor_clicks, default: no) — When enabled,sp_set_post_clicks()returns early ifis_user_logged_in()is true.
Viewing the Data
Open any sponsor's edit screen. The Details sidebar meta box shows the current Impressions and Clicks counts for that sponsor. The same values appear as sortable columns on the Sponsors list screen.
