How to Classify a Website for Ad Targeting
Your ads team needs to target inventory by content and keep campaigns off mismatched or unsafe pages. By the end of this guide, you’ll be able to classify any website into IAB-aligned categories, read confidence scores, and plug the result into your ad-serving or DSP workflow to allowlist, blocklist, or tune bids automatically.
Why Klazify is a strong fit for ad targeting scenarios
Ad targeting depends on knowing what a page or domain is actually about. Klazify analyzes live website content, not just metadata, so you can identify topics and subtopics that matter to context-driven campaigns. For example, an ad set for “breaking news” benefits from precise categorization into a news-related IAB path, while a brand-safety rule might exclude sensitive or irrelevant categories.
- Accurate website categorization using AI: Klazify evaluates on-page content to capture context beyond titles or tags, which is critical for nuanced ad placement decisions (e.g., distinguishing hard news from unrelated content).
- Global coverage: If your campaigns run internationally, multi-language analysis helps you maintain category consistency and apply the same targeting or block logic worldwide.
- Real-time classification: Up-to-date analysis ensures your targeting and safety checks align with what users see now, not last quarter.
- IAB taxonomy mapping: Results include IAB-aligned categories, making it straightforward to translate classifications into your ad system’s targeting fields.
- Simple API integration: A single REST call returns categories, confidence, logos, social links, company details, and tech signals you can use downstream for optimization.
- Compliance and filtering: Contextual understanding supports stricter allow/deny policies for categories you must avoid while maintaining reach.
Below, you’ll implement one request, interpret the response, and wire the results to a practical ad targeting flow (allowlist/blocklist/audit) with caching and batching guidance.
What you’ll build: a minimal ad-targeting classification step
We’ll classify a domain and read:
- The primary category and confidence to drive allow/block logic.
- IAB mappings to plug into your ad system’s category-based targeting.
- Company and logo signals for analytics and creative matching.
We’ll use the main endpoint, then show post-processing and operational tips so you can deploy this at scale.
Endpoint and one working request
Use the categorization endpoint with Bearer authentication. The request body includes a URL you want to classify. The example below classifies a well-known news site. In Klazify’s docs fixture, this URL returns a category of /News with a confidence of 0.97. Your response will also include logo, social, company, and tech fields.
curl -X POST "https://www.klazify.com/api/categorize" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://cbsnews.com"}'
Note: You can create a free account to get an API key and test right away. Failed or unreachable calls are not billed, and the Starter plan is available at $39.99/mo with a 7-day trial. See the Register page to start.
Official example response and how to use it
Here’s the official JSON response format sample. Use it to understand the fields you’ll leverage in your ad logic. Do not alter the structure when integrating a parser.
{
"domain": {
"categories": [
{
"confidence": 0.92,
"name": "/Computers & Electronics/Consumer Electronics",
"IAB-632-596": "Consumer Electronics/Technology & Computing/Consumer Electronics"
},
{
"confidence": 0.89,
"name": "/Internet & Telecom/Mobile & Wireless/Mobile Phones"
}
],
"social_media": null,
"logo_url": "https://klazify.s3.amazonaws.com/2110787991611585019600ed5fb1d1300.04730104.png"
},
"success": true,
"objects": {
"company": {
"url": "https://www.apple.com/",
"name": "Apple",
"city": "Cupertino",
"stateCode": "CA",
"countryCode": "US",
"employeesRange": "100K+",
"revenue": 274515000000,
"raised": null,
"tags": [
"E-commerce",
"Consumer Electronics",
"Mobile",
"B2C"
],
"tech": [
"omniture_adobe_analytics",
"atlassian_confluence",
"successfactors",
"apache_apex",
"talend",
"oracle_peoplesoft",
"salesforce",
"stripe",
"dell_boomi_atomsphere",
"gigya",
"sage_50cloud",
"quickbooks",
"webmethods",
"apache_tomcat",
"alteryx",
"tibco_rendezvous",
"atlassian_jira",
"..."
]
}
},
"domain_registration_data": {
"domain_age_date": "1987-02-19",
"domain_age_days_ago": "13026",
"domain_expiration_date": "2030-02-20",
"domain_expiration_days_left": "123"
},
"similar_domains": [
"bestbuy.com",
"icloud.com",
"microsoft.com",
"macrumors.com",
"google.com",
"samsung.com",
"twitter.com",
"hp.com",
"bhphotovideo.com",
"dell.com"
]
}
How to use key fields for ad targeting:
- domain.categories[].name: Primary category path for targeting or blocking (e.g., match “/News” or equivalent paths you allow/deny).
- domain.categories[].confidence: Use as a threshold for safety or precision (e.g., require ≥0.9 before auto-allowing).
- domain.categories[].IAB-632-596: IAB mapping string that plugs into systems that expect IAB-style category labels.
- domain.logo_url: Optional creative alignment or analytics (e.g., reporting logos on audited placements).
- objects.company.*: Enrichment for CRM, analytics or contextual rules (e.g., “tags” or “tech” can signal vertical alignment).
- domain_registration_data.*: Operational context that can help detect very new or soon-to-expire domains in risk reviews.
- similar_domains[]: Discover related inventory and pre-warm categories for prospective placements or blocklists.
End-to-end: classify, decide, and act
1) Classify the domain
Send the POST request to the categorization endpoint with the URL you’re evaluating for an ad impression or supply-path audit. Cache results (details below) so you don’t re-query on every impression.
2) Interpret category and confidence
For ad targeting, you’ll typically evaluate the first category in domain.categories as the most relevant, then consult the confidence. If your business rules need more context, consider the second category as a fallback or additional signal.
3) Map to your ad platform
If your DSP or ad server uses IAB categories, read the IAB mapping string when present (e.g., IAB-632-596 field in the first category object). If you operate a custom taxonomy, create a mapping dictionary that translates Klazify paths (e.g., “/News” or other hierarchical names) to your internal segments.
4) Execute your action
- Allowlist: If a category matches your target set and confidence meets threshold, bid or place the ad.
- Blocklist: If a category is disallowed, skip the impression or label the placement for QA.
- Audit: Store the category, confidence, and company signals to review where ads ran and justify optimizations.
Code example: Python integration for targeting
This snippet calls the categorize endpoint, reads category and confidence, checks for an IAB mapping, and returns a decision you can use to bid or block. Replace YOUR_API_KEY with your actual key.
import json
import requests
from typing import Dict, Any, Tuple, Optional
API_URL = "https://www.klazify.com/api/categorize"
API_KEY = "YOUR_API_KEY"
# Example policy:
# - Target IAB News-like content (replace with your actual list)
# - Require 0.90+ confidence for automatic allow
TARGET_IAB_PREFIXES = {"News", "News/"} # Example starter set; adjust to your needs
MIN_CONFIDENCE = 0.90
def classify_domain(url: str) -> Dict[str, Any]:
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
payload = {"url": url}
resp = requests.post(API_URL, headers=headers, json=payload, timeout=15)
resp.raise_for_status()
return resp.json()
def extract_primary_category(data: Dict[str, Any]) -> Tuple[Optional[str], Optional[float], Optional[str]]:
"""
Returns (name, confidence, iab_mapping)
"""
try:
cats = data["domain"]["categories"]
if not cats:
return None, None, None
primary = cats[0]
name = primary.get("name")
confidence = primary.get("confidence")
# IAB mapping key may or may not be present; read defensively
iab_mapping = None
for k, v in primary.items():
if k.startswith("IAB-"):
iab_mapping = v
break
return name, confidence, iab_mapping
except (KeyError, TypeError):
return None, None, None
def decision_for_ad_targeting(name: Optional[str], confidence: Optional[float], iab_mapping: Optional[str]) -> str:
if not name or confidence is None:
return "REVIEW" # unknown or incomplete
if confidence < MIN_CONFIDENCE:
return "REVIEW"
# If you rely on IAB, check the mapping string
if iab_mapping:
for p in TARGET_IAB_PREFIXES:
if iab_mapping.startswith(p):
return "ALLOW"
# Otherwise, fall back to Klazify path rules
if name.startswith("/News"):
return "ALLOW"
return "BLOCK"
def main():
url_to_check = "https://cbsnews.com"
data = classify_domain(url_to_check)
name, conf, iab = extract_primary_category(data)
action = decision_for_ad_targeting(name, conf, iab)
# Optional enrichment for logging
logo = data.get("domain", {}).get("logo_url")
company = data.get("objects", {}).get("company", {})
print(json.dumps({
"url": url_to_check,
"category": name,
"confidence": conf,
"iab": iab,
"action": action,
"logo_url": logo,
"company_name": company.get("name"),
"company_tags": company.get("tags")
}, indent=2))
if __name__ == "__main__":
main()
In practice, replace the TARGET_IAB_PREFIXES and the fallback “/News” rule with the categories your campaign targets, and store the result per domain to avoid repetitive lookups.
How to wire the returned fields into your ad pipeline
| Field | What it tells you | Typical ad-targeting use |
|---|---|---|
| domain.categories[0].name | Hierarchical category path | Primary allow/block rule based on content type |
| domain.categories[0].confidence | Confidence score (0–1) | Set thresholds to auto-allow, auto-block, or send to review |
| domain.categories[0].IAB-* | IAB mapping string | Feed directly into platforms that expect IAB segments |
| objects.company.tags | Business-relevant tags | Secondary targeting signals or analytics enrichment |
| domain.logo_url | Logo image URL | Creative/brand audits and reporting dashboards |
| similar_domains[] | Related sites | Prospect allowlists/denylists or pre-warm cache |
Operational guidance for scale
Caching strategy
- Key your cache by normalized domain (e.g., lowercase, strip protocol and www).
- Set a TTL appropriate to your needs. For ad targeting, categories do not change frequently; a moderate TTL can cut latency and cost. If you detect major site changes, refresh on-demand.
- Cache misses: If a domain is unknown, classify once and cache the result immediately.
Batching and throughput
- Batch domains in your job queue rather than hitting the API on every inbound impression.
- When you see a new domain in the bidstream or logs, enqueue it for classification and serve a default policy while it’s pending (see “Unknown or new domains” below).
- Use a small worker pool with backoff and jitter to respect service stability. Consult the Documentation for current recommendations.
Unknown or new domains
- If you have no cached category yet, apply a conservative default (e.g., REVIEW or BLOCK) until the classification returns.
- Retry logic: If a call fails due to a network issue, retry with exponential backoff. Failed or unreachable calls are not billed.
- Consider scheduling periodic refreshes for high-traffic or high-risk domains.
Mapping to your own taxonomy
- Prefer IAB mapping if your stack is IAB-native. The response may include a field like the IAB-632-596 mapping in the first category object.
- If you run a custom taxonomy, build a dictionary from Klazify paths (e.g., “/News”, “/Sports/Team Sports”) to your internal nodes. Maintain this mapping in version control.
- If multiple categories are returned, map the primary and keep alternates as backstops. You can use alternates when confidence ties occur.
Latency and fallbacks
- Asynchronous enrichment: For real-time bidding, lookups should come from your cache. Populate and update the cache out of band.
- Graceful degradation: If the API is temporarily unreachable, serve your default policy and log the event for reprocessing.
Data retention and audits
- Store the category, confidence, and timestamp per domain. This enables campaign audits (“where did we run?”) and reproducibility.
- Archive raw responses for troubleshooting and quality checks, especially early in rollout.
Example policy flows for ad targeting
Allowlisting by category
- Target list: e.g., “/News” and selected subpaths.
- Decision: If primary category starts with an allowed path and confidence ≥ threshold, ALLOW; else, REVIEW or BLOCK.
Blocklisting by category
- Block list: Categories you must avoid.
- Decision: If any returned category matches a blocked path, BLOCK regardless of confidence; else continue normal evaluation.
Bid modifiers by confidence
- High-confidence matches: Full bid.
- Mid-confidence matches: Reduced bid or send to review queue.
- Low-confidence: Skip or label for manual QA.
Practical tips that save time
- Normalize inputs: Always canonicalize domains before lookup (protocol, subdomain, trailing slash) to maximize cache hits.
- Handle nulls defensively: social_media may be null; logo_url may be missing on some domains—check before use.
- Use similar_domains to expand allowlists: Classify those proactively to reduce cold starts in live traffic.
- Version your mapping tables: When you adjust category-to-campaign mappings, keep a version identifier in your logs for accurate post-campaign analysis.
Monitoring and QA
- Track classification coverage across your top domains to catch gaps early.
- Spot-check edge cases: multilingual sites, user-generated content, or fast-changing homepages.
- Alert on high drift: If a site’s category changes frequently, review manually and shorten the TTL for that domain.
Where to go next
Explore endpoint details, schema notes, and best practices in the Documentation. For managing credentials and permissions in larger teams, see the MCP. Create an account to test the endpoint and plug it into your pipeline today on the Register page.
FAQ
-
Can I classify at the page level instead of just the domain?
Yes. Send the specific URL you want to evaluate in the same request body. This helps when sites host diverse content across sections. -
How should I set a confidence threshold?
Set thresholds by your risk tolerance. Many teams start with a stricter threshold for automatic allow and route mid-confidence results to review. -
What if a domain changes content frequently?
Shorten your cache TTL for that domain and schedule periodic refreshes. Keep timestamps so you can reconcile decisions with the classification time. -
How do I migrate from a custom taxonomy?
Map your segments to Klazify category paths or use IAB mappings where provided. Keep a translation table and update it as your targeting needs evolve. -
Will I be charged for failed requests?
No. Failed or unreachable calls are not billed. You can also start on the Starter plan ($39.99/mo) with a 7-day trial to evaluate fit before scaling.
Ready to test with your inventory? Create a free account and run your first classifications today. Start here: Register. For more product information, visit https://www.klazify.com and consult the Documentation whenever you need field-level details.
Ready to use Klazify?
Start classifying websites, enriching company data, and exploring web intelligence.
Get Started Free