Skip to main content

Module ctr

Module ctr 

Source
Expand description

Click-through rate (CTR) tracking for thumbnails and content previews.

Tracks impression and click events per item (thumbnail, preview card, etc.) and computes click-through rates, confidence intervals, and performance rankings across a catalogue of content items.

§Definitions

  • Impression — an item was displayed to a viewer.
  • Click — a viewer interacted with (clicked/tapped) the item.
  • CTRclicks / impressions expressed as a fraction in [0.0, 1.0].

Wilson score confidence intervals are used for the CTR bounds because they remain valid even for small sample sizes and extreme rates (near 0 or 1) unlike the normal approximation.

§Example

use oximedia_analytics::ctr::{CtrTracker, CtrVariant};

let mut tracker = CtrTracker::new();
tracker.record_impression("thumb_a");
tracker.record_impression("thumb_a");
tracker.record_click("thumb_a");

let stats = tracker.stats("thumb_a").unwrap();
assert_eq!(stats.impressions, 2);
assert_eq!(stats.clicks, 1);
assert!((stats.ctr() - 0.5).abs() < 1e-6);

Structs§

CtrStats
Raw impression/click counts and derived metrics for a single item.
CtrTracker
Tracks CTR metrics for an arbitrary number of items.
CtrVariant
A summarised variant for ranking and A/B reporting.