How to Get Monthly Visits in PHP

October 29, 2026
How to Get Monthly Visits in PHP

You’re enriching signups, scoring leads, or auditing where your ads run, and you need a reliable way to retrieve a domain’s monthly visits and engagement—then plug those metrics into your existing PHP pipeline. By the end of this guide, you’ll call Klazify’s Domain Traffic Intelligence endpoint, parse monthly_visits and engagement details, and operationalize them with caching, batching, and category mapping that fits production workflows.

Why Klazify is the best fit for extracting monthly visits at scale

When you’re building a PHP workflow that depends on accurate traffic signals per domain, classification quality and integration simplicity matter as much as the numbers you fetch. Klazify brings together traffic intelligence and robust classification in one API, so you don’t have to stitch multiple providers.

Illustration: How to Get Monthly Visits in PHP
  • Accurate website categorization using AI: Klazify analyzes full website content, not just metadata, which helps you align traffic metrics (like monthly_visits) with precise topical context for better scoring and filtering in your PHP apps.
  • Global coverage: If your signup flow or ad checks receive domains from multiple languages and regions, you can classify them consistently and interpret country_rank and top_countries alongside monthly_visits.
  • Real-time classification: Up-to-date analysis ensures monthly visits and engagement you pull are contextualized with current categories rather than stale, prebuilt lists.
  • Industry-level categories (IAB taxonomy): Leveraging IAB taxonomy lets you match traffic metrics to industry-standard categories for ad tech, brand safety, and analytics pipelines.
  • Simple API integration: A clean REST interface and standard JSON output make it straightforward to call from PHP or any server-side runtime—ideal when you need to transform traffic metrics before storing them.
  • Compliance and filtering: Combine category signals with traffic_sources to block or down-rank high-risk or low-relevance domains in your flows.

If your goal is to get monthly visits in PHP, Klazify’s traffic and categorization endpoints let you tie audience scale (monthly_visits), market context (global_rank, country_rank, category_rank), and safety (IAB categories) into a single enrichment step.

Scenario: Enriching a PHP signup with monthly visits and engagement

Suppose your signup form includes a company domain. You want to enrich it with monthly_visits and engagement (like average visit duration or bounce rate), then route high-traffic domains to a fast-track onboarding. You’ll make a server-side POST request to the Domain Traffic Intelligence endpoint, parse monthly_visits and engagement fields, cache the response keyed by domain, and keep the enrichment near real time without overloading your backend.

We’ll show you a copy-paste cURL, a PHP example for production use, and a JavaScript example you can reuse in backend runtimes. We’ll also include the official categorization JSON sample so you can see how to combine traffic signals with category intelligence when needed.

The endpoint you’ll call

Traffic data, including monthly visits, is available via:

  • POST https://www.klazify.com/api/domain_traffic_intelligence

Auth is via Bearer token in the Authorization header. Body is JSON with the url field pointing to the target domain or URL.

Important operational notes:

  • Failed or unreachable calls are not billed.
  • Starter is $39.99/mo with a 7-day trial; create a free account to get an API key.
  • Cache per domain to reduce repeated calls during spikes (e.g., same domain across multiple signups).
  • Handle unknown or new domains gracefully—retry with backoff if needed and queue incremental refresh jobs.

Get an API key by signing up at Register. Review endpoint details in the Documentation.

cURL: Fetch monthly visits and engagement

This is a complete, copy-paste request using the example domain for demonstration purposes:

curl -X POST "https://www.klazify.com/api/domain_traffic_intelligence" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"url":"https://cbsnews.com"}'

What to expect in the JSON response:

  • global_rank, country_rank, category_rank: Overall, country-level, and category-level positions.
  • monthly_visits: Estimated monthly visits (total).
  • engagement: Engagement metrics (e.g., visit duration, pages per visit, bounce rate if present).
  • traffic_sources: Distribution across channels (e.g., direct, search, social, referrals).
  • top_countries: Breakdown of traffic share by country.

Use these fields to enrich your CRM or signup database, derive lead scores, or filter ad placements. If a field is missing for a given domain (new or low-signal sites), log and degrade gracefully—don’t block user flows.

PHP: Production-friendly enrichment snippet

The following PHP example demonstrates calling the endpoint, extracting monthly_visits and engagement, and handling common operational details (timeouts, JSON checks). Insert it into your signup processing or a queue worker.

<?php
$apiKey = getenv('KLAZIFY_API_KEY'); // or hardcode for testing only
$endpoint = 'https://www.klazify.com/api/domain_traffic_intelligence';

$payload = json_encode([
  'url' => 'https://cbsnews.com'
]);

$ch = curl_init($endpoint);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  'Content-Type: application/json',
  'Authorization: Bearer ' . $apiKey
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15); // network timeout
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$err = curl_error($ch);
curl_close($ch);

if ($err) {
  // Not billed for unreachable calls; log and fallback
  error_log('Klazify error: ' . $err);
  // fallback path...
  exit;
}

if ($httpCode < 200 || $httpCode >= 300) {
  error_log('Klazify HTTP ' . $httpCode . ' body: ' . $response);
  // fallback path...
  exit;
}

$data = json_decode($response, true);
if (!is_array($data)) {
  error_log('Invalid JSON from Klazify.');
  exit;
}

// Safely read expected fields
$monthlyVisits = $data['monthly_visits'] ?? null;
$globalRank = $data['global_rank'] ?? null;
$countryRank = $data['country_rank'] ?? null;
$categoryRank = $data['category_rank'] ?? null;
$engagement = $data['engagement'] ?? null; // may include nested metrics
$trafficSources = $data['traffic_sources'] ?? null;
$topCountries = $data['top_countries'] ?? null;

// Example: write to your database or scoring service
// saveTrafficEnrichment($domain, $monthlyVisits, $engagement, $globalRank, $countryRank, $categoryRank, $trafficSources, $topCountries);

// Basic conditional routing
if (is_numeric($monthlyVisits) && $monthlyVisits > 1000000) {
  // Fast-track onboarding or route to enterprise SDR
} else {
  // Standard flow
}
?>

Note on caching: store the full response keyed by the domain and a short TTL (for example, a few days) to limit repeated lookups for the same company during busy periods. For batch imports, queue jobs by domain and dedupe.

JavaScript: Backend example (Node.js, Deno, or serverless)

If your backend uses JavaScript, this snippet fetches the same metrics and illustrates parsing the main fields.

import fetch from 'node-fetch';

const API_KEY = process.env.KLAZIFY_API_KEY;
const url = 'https://cbsnews.com';

async function getTraffic(urlToCheck) {
  const res = await fetch('https://www.klazify.com/api/domain_traffic_intelligence', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ url: urlToCheck }),
    // optional: control timeouts via AbortController in production
  });

  if (!res.ok) {
    const body = await res.text();
    throw new Error(`Klazify HTTP ${res.status}: ${body}`);
  }

  const data = await res.json();

  const monthlyVisits = data.monthly_visits ?? null;
  const engagement = data.engagement ?? {};
  const globalRank = data.global_rank ?? null;
  const countryRank = data.country_rank ?? null;
  const categoryRank = data.category_rank ?? null;
  const trafficSources = data.traffic_sources ?? {};
  const topCountries = data.top_countries ?? [];

  return {
    monthlyVisits,
    engagement,
    globalRank,
    countryRank,
    categoryRank,
    trafficSources,
    topCountries
  };
}

getTraffic(url)
  .then(console.log)
  .catch(err => {
    console.error('Traffic fetch failed:', err.message);
  });

Production tip: implement retries with jitter for transient network errors. Since unreachable calls are not billed, you can retry conservatively without incurring extra cost, but still respect your own queue capacity.

Combining traffic intelligence with categorization

For brand safety, ad targeting, or CRM enrichment beyond just visits, you’ll often want to merge traffic metrics with IAB categories. Use the categorization endpoint to get category labels, confidence scores, and additional company context from the same domain.

  • Endpoint: https://www.klazify.com/api/categorize
  • Use to: classify the domain and map it to IAB taxonomy for policy checks and analytics joins.

Here is the official categorization JSON example. Use it as a reference for the data envelope and the IAB mapping fields you can join with traffic signals:


{
    "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 it:

  • domain.categories[].name: join against your policy or routing rules (e.g., safe-to-run ads, high-CPM verticals).
  • domain.categories[].confidence: apply thresholds for automated vs. manual review.
  • domain.logo_url: store for CRM enrichment or UI thumbnails.
  • objects.company fields: map to customer profiles; augment routing decisions.
  • similar_domains: helpful for prospecting or deduping multi-property portfolios.

Additional JSON samples for integration reference

Below are additional complete examples of the same categorization JSON structure for test fixtures and parser validation. Use them to verify your mappers, ensure deterministic parsing, and build unit tests around common fields you’ll rely on in production.


{
    "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"
    ]
}

{
    "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 monthly_visits and related fields in your pipeline

Once you parse traffic intelligence, you can make quick decisions at ingestion time. Here’s how teams typically use each field in production:

  • monthly_visits: Treat as a primary signal for audience scale. Use numeric thresholds to segment tiers (e.g., enterprise candidate vs. SMB). Cache raw values for trend analysis.
  • global_rank: Use as a normalized proxy for overall web prominence. When comparing domains from different industries, rank remains stable even if categories vary.
  • country_rank: Route prospects to geo-specific teams; align with region-based SLAs or ad inventory constraints.
  • category_rank: Combine with categorization results to prioritize top-ranked domains in your target verticals.
  • engagement: Longer visit durations and higher pages-per-visit can signal deeper user intent. Weigh this into lead scores or ad suitability checks.
  • traffic_sources: If traffic skews to search, emphasis might be on organic content partnerships; if social-heavy, adjust outreach strategy.
  • top_countries: Align with localization, language support, and compliance reviews.

Batching, rate limits, and caching strategy

You’ll likely run traffic enrichment in batches (e.g., nightly backfills) and also in real time (signup, ad checks). Recommended approach:

  • Batch queues: De-duplicate repeated domains; collapse duplicates into a single call per batch to minimize API usage and lower latency.
  • Caching: Cache results per domain with a TTL. For fast-moving sites, keep the TTL shorter; for stable sites, refresh less frequently.
  • Backoff and retries: Use exponential backoff for transient errors. Since unreachable calls aren’t billed, it’s safe to retry judiciously.
  • Partial data: Some domains may return limited fields. Store whatever is provided and schedule a later refresh job.

For detailed specs, see the Documentation. If you need help designing a high-throughput ingestion flow, visit MCP or contact support via the dashboard.

Mapping Klazify categories to your internal taxonomy

If your organization uses a custom taxonomy, map it to IAB categories from the categorization endpoint. Keep a lookup table of patterns from domain.categories[].name and IAB codes to your internal segment IDs. Maintain a confidence threshold to determine auto-mapping versus manual review. Store the mapping in your data warehouse and apply during enrichment so traffic intelligence and categories stay aligned in one record.

Operational guardrails for unknown or new domains

Unknown domains are common in early-stage signups and user-generated content. To avoid blocking flows:

  • Queue-and-proceed: Accept the signup, enqueue the domain for enrichment, and notify sales or ops only if enrichment yields high-value signals.
  • Progressive enhancement: First attempt traffic intelligence; if insufficient, attempt categorization for context; finally, schedule a delayed re-check.
  • User feedback: Avoid hard errors to end users; surface enrichment results internally.

Reference: Official categorization response (for testing joins)

Below is the official categorization response again, which you can use for tests and to design your joins between traffic data and categories. This helps validate your schema evolution strategy as you expand enrichment fields.


{
    "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"
    ]
}

Common pitfalls and how to avoid them

  • Dropping nulls: Some fields may be null if not available. Keep your schema flexible and preserve nulls for analytics accuracy.
  • Overfetching hot domains: Cache aggressively for domains that appear frequently (e.g., popular media or SaaS sites).
  • Ignoring engagement: Monthly visits alone doesn’t capture depth. Include engagement for better signal.
  • Skipping category joins: Without categories, you can’t easily set policy or brand safety gates; fetch category data where relevant.

Where to go next

Sign up to get your API key and start sending requests from PHP or any backend. The Starter plan is $39.99/mo with a 7-day trial, and unreachable calls are not billed. Create your account here and start testing in minutes: Register. Explore more capabilities and examples in the Documentation. Visit the homepage anytime: https://www.klazify.com and Klazify.

FAQ

  • Can I call the traffic endpoint directly from client-side JavaScript?
    Use a server-side environment (PHP, Node.js, etc.). Keep your API key private. If you must call from the client, proxy through your backend.
  • How often should I refresh monthly_visits?
    Depends on your use case. For high-traffic domains in ad tech or lead scoring, a shorter TTL is useful. For stable CRM enrichment, refresh less frequently and prioritize cache hits.
  • What happens if a domain has limited or no data?
    The response may omit some fields. Store what’s available and schedule a retry. Ensure your pipeline degrades gracefully without blocking user actions.
  • How do I map IAB categories to my own taxonomy?
    Maintain a lookup table keyed by domain.categories[].name and IAB fields, apply a confidence threshold, and store the final mapping alongside traffic fields in your warehouse.
  • Are unsuccessful requests billed?
    Failed or unreachable calls are not billed.

Ready to pull monthly visits into your PHP stack? Create your free account and start integrating Klazify now: Register. For implementation details, examples, and schema references, see the Documentation and MCP.

Ready to use Klazify?

Start classifying websites, enriching company data, and exploring web intelligence.

Get Started Free