Algo-Feed Ad Space Auction Marketplace Real-Time Bidding

Place your bid for sponsored placement slots directly inside the algo-feed timeline. Ads are hyper-targeted using our extensive tracking cookie matrix.

Live Auction Order Book Top Bids
Campaign Targeting Bid CPM Status
Vaporwave Synth VST WebAudio Enthusiasts $24.00 Winning Slot #1
Devon Linux VPS Hosting Maximum Tracking $19.50 Winning Slot #2
Chiptune MIDI Cables Retro Gaming Context $16.00 Queued
Cookie Tracking Box Simulation · Restored

Restored from the original advertisers page. This is the box that got lost in the responsive rewrite. In v2 it is a full-width main box on the bottom, not a sidebar. No pixel is active on this page.

Campaign Integration Preview Simulation

Future integration point for campaign delivery and aggregate impression reporting. No tracking pixels or cross-site cookies are active on this page. Moved to the bottom in v2 — it is a main box, not a sidebar.

Planned only. The eventual event endpoint should accept first-party, consent-aware aggregate events and reject arbitrary user identifiers.
Advertiser Backend Blueprint Proposed · Not connected

A proposed implementation map for turning this front-end auction simulation into a real, auditable marketplace. The snippets below are interface contracts and placeholders, not deployed endpoints.

01 / API endpoints & request flow

Keep the API consistent with the existing tinyfiles PHP pattern: each endpoint loads /api/bootstrap.php, uses json_in(), returns through json_out(), and uses prepared PDO statements.

GET    /api/ads/marketplace
POST   /api/ads/campaigns
GET    /api/ads/campaigns/{id}
PATCH  /api/ads/campaigns/{id}
POST   /api/ads/campaigns/{id}/bids
GET    /api/ads/auctions/{id}/bids
GET    /api/ads/reports/{campaign_id}
POST   /api/ads/events       (first-party aggregate events)
// POST /api/ads/campaigns/{id}/bids
{
  "bid_cpm": 18.50,
  "placement": "algo_feed",
  "targeting": ["webaudio"],
  "daily_budget": 75.00,
  "currency": "USD"
}

// Response
{
  "ok": true,
  "bid_id": "uuid",
  "status": "pending_review",
  "message": "Bid received; not yet eligible to serve."
}
Suggested lifecycle: advertiser account → campaign draft → review/approval → scheduled auction → aggregate reporting. A submitted bid should never be described as a winning placement until the server-side auction has actually settled.
02 / Database tables

Proposed MySQL/InnoDB tables. Keep campaign ownership and financial state separate from public campaign creative.

advertisers
  id CHAR(36) PRIMARY KEY
  owner_member VARCHAR(80) NOT NULL
  display_name VARCHAR(120) NOT NULL
  status ENUM('pending','active','suspended')
  created_at DATETIME

ad_campaigns
  id CHAR(36) PRIMARY KEY
  advertiser_id CHAR(36) NOT NULL
  title VARCHAR(120) NOT NULL
  ad_copy VARCHAR(140) NOT NULL
  destination_url VARCHAR(2048)
  status ENUM('draft','review','active','paused','ended')
  daily_budget DECIMAL(10,2)
  starts_at DATETIME
  ends_at DATETIME

ad_bids
  id CHAR(36) PRIMARY KEY
  campaign_id CHAR(36) NOT NULL
  placement VARCHAR(40) NOT NULL
  bid_cpm DECIMAL(10,2) NOT NULL
  targeting_json JSON
  status ENUM('pending','eligible','won','lost','rejected')
  created_at DATETIME

ad_auction_results
  id BIGINT AUTO_INCREMENT PRIMARY KEY
  placement VARCHAR(40) NOT NULL
  campaign_id CHAR(36) NOT NULL
  bid_id CHAR(36) NOT NULL
  clearing_cpm DECIMAL(10,2) NOT NULL
  settled_at DATETIME

ad_daily_stats
  campaign_id CHAR(36) NOT NULL
  stat_date DATE NOT NULL
  impressions BIGINT DEFAULT 0
  clicks BIGINT DEFAULT 0
  spend DECIMAL(12,4) DEFAULT 0
  PRIMARY KEY (campaign_id, stat_date)
Add foreign keys, indexes for status/date/placement lookups, and transactional budget checks before accepting or settling bids. Store money as DECIMAL, never floating point.
03 / Auction engine & validation

The browser submits intent; the server owns eligibility, ranking, budget enforcement, and settlement. A scheduled worker can close auction windows and write immutable results.

1. Validate campaign is approved, active, and in schedule.
2. Validate bid >= configured floor and within account limits.
3. Lock campaign budget row inside a DB transaction.
4. Filter eligible campaigns for the placement.
5. Apply approved contextual categories (not sensitive traits).
6. Rank eligible bids; apply deterministic tie-break.
7. Settle the winner and reserve/debit budget atomically.
8. Emit ad.auction_settled through the existing events pattern.
9. Update aggregate daily reporting asynchronously.

Validate title and copy lengths, URL scheme/host, bid precision, budget, targeting allowlist, ownership, and request method. Use idempotency keys for bid submissions to prevent accidental duplicates.

04 / Privacy, security & abuse controls

Build this as a contextual, first-party ad system. Do not implement the old mockup's cross-site cookie harvesting or hidden fingerprinting. The only tracker allowed is the consent-gated first-party script defined in §06.

Authentication: member session for advertiser actions
Authorization: campaign must belong to authenticated advertiser
Admin review: moderator bearer token for approvals
Rate limits: nginx proxy layer, consistent with existing API
Input: strict allowlists, size caps, prepared SQL statements
Events: aggregate counts; no raw IP or persistent user profile
Reporting: minimum aggregation thresholds
Billing: ledger entries + idempotent payment webhooks
The current tinyfiles bootstrap already establishes PDO, JSON helpers, member sessions, moderator-token checks, and a design where nginx handles IP-based rate limiting. Reuse those conventions rather than inventing a parallel auth stack.
05 / Front-end integration contract

When the API exists, replace the local demo submit handler with fetch calls. Keep the page useful if the API is unavailable, and make simulated data visually distinct from live data.

GET /api/ads/marketplace
{
  "ok": true,
  "mode": "simulation",
  "floor_cpm": 14.50,
  "bids": [
    {
      "campaign_id": "example-id",
      "title": "Example campaign",
      "targeting": ["webaudio"],
      "bid_cpm": 18.50,
      "status": "pending_review"
    }
  ]
}

Recommended response states: loading, live, simulation, empty, validation error, unauthorized, and server unavailable. Never show fabricated live metrics as actual traffic or revenue.

06 / Cookie tracker script — what we might need

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.