Skip to main content
Use this recipe when PHP runs for every monitored page request and no managed log-stream connector is selected. It works on WordPress and on any other PHP 7.4 site: the generated tracker is the same, and only the installation step differs. The tracker reports eligible HTML page requests through the Generic HTTP collector endpoint.
Full-page caches and CDNs can serve a response without running WordPress or PHP. Those requests cannot be observed by this recipe. Use an edge or managed log collector when the traffic you need to measure bypasses PHP.

Before you start

You need:
  • access to Measure > Crawler Analytics > Settings for the brand;
  • PHP 7.4 or later with the cURL extension enabled;
  • on WordPress, access to the active theme directory and functions.php;
  • on another PHP site, access to the front controller, such as index.php, or to the PHP configuration;
  • outbound HTTPS access from PHP to https://www.qwairy.co;
  • a server-side secret facility or configuration excluded from source control.
On WordPress, theme updates can replace custom files. Use a child theme and record the installation. Only activate one Crawler Analytics delivery source for the brand.

Create and protect the key

  1. In Crawler Analytics settings, select WordPress.
  2. Select Create Key.
  3. Enter a descriptive name and the IANA time zone used for daily analytics.
  4. Copy the plaintext secret when it appears. Qwairy shows only its prefix later.
  5. Store it in server-side configuration. Do not commit it to the theme, expose it to JavaScript, place it in a URL, or write it to logs.
Use this key for WordPress and for other PHP sites. The recipe uses the Generic HTTP provider contract, and its endpoint is https://www.qwairy.co/api/v1/logs/ingest.

Add the generated tracker

Create qwairy-tracker.php with the current generated recipe. Place it in the active theme directory on WordPress, or next to your front controller on another PHP site:
Then load the tracker once per request. Choose the tab that matches your site.
Add the setup snippet to functions.php:
If functions.php already starts with <?php, add only the two statements and do not insert a second opening tag.With a child theme, place qwairy-tracker.php in the child theme directory and replace get_template_directory() with get_stylesheet_directory(). get_template_directory() returns the parent theme directory, so the file would not be found.
YOUR_API_KEY is a placeholder. Replace it only during deployment with the server-side value. If your host exposes secrets to PHP as environment variables, keep the value out of source code:
Do not initialize the tracker twice. The generated function names are global, so confirm that no other file, plugin, or theme defines qwairy_init or qwairy_send_log.

Verify delivery

Use an uncached HTML page that returns 200, and replace the example hostname. The tracker accepts GET, not HEAD. This synthetic request creates a crawler observation in the current analytic day:
  1. Confirm the request returns the expected page status.
  2. Confirm that PHP handled the request rather than a CDN or full-page cache.
  3. In Qwairy, wait for the connector to move from pending to connected after the accepted event reaches a daily rollup.
  4. Open the current analytic day and look for /docs/qwairy-collector-check.
If the page loads but the connector stays pending, verify the cURL extension, outbound HTTPS, key, hostname, User-Agent, current timestamp, content type, and ignored-path rules.

Limits and behavior

  • The generated tracker reports only GET requests with a matching User-Agent.
  • Static file extensions and paths beginning with /wp-admin/, /wp-json/, /api/, or /admin/ are ignored.
  • A response with an explicit content type is reported only when it contains text/html.
  • Delivery is a blocking cURL call during PHP shutdown with a five-second timeout. The generated tracker has no retry queue and does not inspect the Qwairy response.
  • The integration route allows a burst of 120 ingestion requests per minute. Responses above that rate are not retried by the generated tracker.
  • The endpoint applies hostname validation, Qwairy exclusions, maintained crawler classification, a 72-hour late-arrival window, and shared ingestion ceilings.
  • The shared technical ceilings are 10,000,000 events per integration per day and 200,000,000 events per billed team per day.
  • The collector observes requests. It does not prove indexing, model training, or citation use.

Rotate or roll back

To rotate the key, create a replacement in Qwairy, update the server-side value, confirm a new accepted observation, and then delete the previous key. To roll back the tracker:
  1. Remove the require_once and qwairy_init call from functions.php or from your front controller.
  2. Deploy and clear the relevant application or host caches.
  3. Confirm the site still serves normally and no new tracker observations arrive.
  4. Remove qwairy-tracker.php and the server-side secret.
  5. Revoke the corresponding Qwairy key.
Disabling delivery creates an analytics coverage gap. Check delivery-continuity warnings before comparing periods that cross the rollback.