This is the backend for the Cookie Tracking Box above. If we ever ship a tracker, this is the only version we ship: first-party, consent-gated, aggregate-only. No third-party cookies, no cross-site harvesting, no fingerprinting.
// What the advertiser pastes (from Cookie Tracking Box)
<script src="https://tinyfiles.tv/track.js?id=adv_live" data-consent="required" defer></script>
<noscript><img src="https://tinyfiles.tv/pixel.gif?campaign=adv_live" alt="" /></noscript>
// What track.js must do (first-party, consent-aware)
1. Do nothing until consent === granted. If no consent, exit.
2. Queue events locally: { campaign_id, placement, event: impression|click }
3. Send with navigator.sendBeacon to POST /api/ads/events
4. Never read/write third-party cookies, never fingerprint, never store IP
5. Respect DNT / Global Privacy Control — if set, do not send
// Server endpoints for the tracker
GET /api/ads/track.js?campaign=adv_live - returns JS above, Content-Type: application/javascript
GET /api/ads/pixel.gif?campaign=adv_live - 1x1 transparent GIF, logs 1 aggregate event, no Set-Cookie if no consent
POST /api/ads/events - { campaign_id, placement, event } - aggregate only
// track.js - sketch (not deployed)
(function(){
if (document.currentScript?.dataset.consent !== 'granted') return;
if (navigator.doNotTrack === '1') return;
function send(evt){
var body = JSON.stringify({ campaign_id: 'adv_live', placement: 'algo_feed', event: evt });
if (navigator.sendBeacon) navigator.sendBeacon('/api/ads/events', body);
}
// impression once per view, click only on the ad element itself
send('impression');
})();
// Cookie / storage rules if we ever set anything
Set-Cookie: tf_ad_consent=granted; Path=/; Max-Age=15552000; SameSite=Lax; Secure; HttpOnly
- First-party only, tinyfiles.tv domain only
- No third-party Set-Cookie, no _ga / _fbp / fingerprint IDs
- Aggregate tables only - see ad_daily_stats, never a per-user profile table
// Proposed table for consent + aggregate counts (no user profile)
ad_consent_log
id CHAR(36) PRIMARY KEY
consent ENUM('granted','denied') NOT NULL
placement VARCHAR(40) NOT NULL
created_at DATETIME
// Reuse ad_daily_stats for counts:
ad_daily_stats (campaign_id, stat_date) -> impressions, clicks, spend
// Never create: user_profiles, fingerprints, cross_site_history
Build order if we do this: 1) consent UI + ad_consent_log, 2) POST /api/ads/events with aggregate-only validation, 3) track.js that respects consent/DNT, 4) pixel.gif fallback, 5) daily aggregation job. Do not ship the snippet on any core creative view - only on the algo-feed ad slot, and only after consent.