'acceptrics_sanitize_account_id', ]); register_setting('acceptrics_settings_group', 'acceptrics_enable_banner'); register_setting('acceptrics_settings_group', 'acceptrics_blocker_detect_enabled'); register_setting('acceptrics_settings_group', 'acceptrics_consent_mode_enabled'); } add_action('admin_init', 'acceptrics_register_settings'); // AJAX: Save adaptive routing strategy from the admin active-state card. add_action('wp_ajax_acceptrics_save_relay_strategy', function () { check_ajax_referer('acceptrics_relay_nonce', 'nonce'); if (!current_user_can('manage_options')) { wp_send_json_error('Unauthorized'); } $strategy = sanitize_text_field(wp_unslash($_POST['strategy'] ?? '')); if (!in_array($strategy, ['adaptive', 'always_relay', 'always_direct'], true)) { wp_send_json_error('Invalid strategy.'); } update_option('acceptrics_relay_strategy', $strategy); wp_send_json_success(['strategy' => $strategy]); }); function acceptrics_sanitize_account_id($value) { $value = sanitize_text_field($value); return preg_replace('/[^a-zA-Z0-9_\-]/', '', $value); } // AJAX: Create an Acceptrics account from the settings page for customers who // installed the plugin without one. Calls the account Lambda server-side (no // CORS exposure), saves the returned code, and enables the banner. add_action('wp_ajax_acceptrics_create_account', 'acceptrics_handle_create_account'); function acceptrics_handle_create_account() { check_ajax_referer('acceptrics_create_account_nonce', 'nonce'); if (!current_user_can('manage_options')) { wp_send_json_error(['message' => 'Unauthorized.']); } // Idempotence guard: never overwrite an already-configured account. if (get_option('acceptrics_account_id', '') !== '') { wp_send_json_error(['message' => 'An account code is already configured. Remove it first if you want to create a new account.']); } $email = sanitize_email(wp_unslash($_POST['email'] ?? '')); if (!is_email($email)) { wp_send_json_error(['message' => 'Please enter a valid email address.']); } $geo_area = sanitize_text_field(wp_unslash($_POST['geo_area'] ?? 'eea')); if (!in_array($geo_area, ['eea', 'worldwide'], true)) { $geo_area = 'eea'; } // Mirror the acceptrics.com wizard defaults so a plugin-created account // behaves identically to a wizard-created one. $document = [ 'gcmAdvanced' => true, 'backgroundColor' => '', 'fontColor' => '', 'geoArea' => $geo_area, 'respectGPC' => true, 'useTranslation' => true, 'bannerStyle' => '', 'ec' => false, 'autoIncludeAllCookies' => true, 'theme' => 'theme-default', ]; $response = wp_remote_post(ACCEPTRICS_ACCOUNT_API_URL, [ 'timeout' => 20, 'headers' => ['Content-Type' => 'application/json'], 'body' => wp_json_encode(['email' => $email, 'document' => $document]), ]); if (is_wp_error($response)) { wp_send_json_error(['message' => 'Could not reach Acceptrics. Please check your connection and try again.']); } $status = wp_remote_retrieve_response_code($response); $data = json_decode(wp_remote_retrieve_body($response), true); if (is_array($data) && ($data['message'] ?? '') === 'Conflict') { wp_send_json_error(['message' => 'This email is already registered. Your account code is in your welcome email, ' . 'or log in to your account to retrieve it.' ]); } if ($status === 429) { wp_send_json_error(['message' => 'Too many attempts. Please wait a few seconds and try again.']); } if ($status !== 200 || !is_array($data) || empty($data['accountNum'])) { wp_send_json_error(['message' => 'Account creation failed. Please try again, or ' . 'sign up at acceptrics.com.' ]); } $account_id = acceptrics_sanitize_account_id($data['accountNum']); if ($account_id === '') { wp_send_json_error(['message' => 'Received an invalid account code. Please try again.']); } $GLOBALS['acceptrics_skip_account_event'] = true; update_option('acceptrics_account_id', $account_id); update_option('acceptrics_enable_banner', 1); // Remember the region so the Status card can explain where the banner shows. update_option('acceptrics_geo_area', $geo_area); $GLOBALS['acceptrics_skip_account_event'] = false; acceptrics_track('wp_account_created', ['method' => 'embedded_signup', 'geo_area' => $geo_area]); wp_send_json_success(['accountNum' => $account_id]); } function acceptrics_is_wp_consent_api_active() { include_once ABSPATH . 'wp-admin/includes/plugin.php'; return is_plugin_active('wp-consent-api/wp-consent-api.php'); } // Enqueue relay-setup.js only on our settings page. function acceptrics_enqueue_relay_scripts($hook) { if ($hook !== 'settings_page_acceptrics-consent-banner') { return; } wp_enqueue_script( 'acceptrics-relay-setup', ACCEPTRICS_PLUGIN_URL . 'includes/js/relay-setup.js', ['jquery'], ACCEPTRICS_VERSION, true ); wp_localize_script( 'acceptrics-relay-setup', 'acceptricsRelayData', acceptrics_relay_get_js_data() ); wp_enqueue_script( 'acceptrics-account-create', ACCEPTRICS_PLUGIN_URL . 'includes/js/account-create.js', ['jquery'], ACCEPTRICS_VERSION, true ); wp_localize_script( 'acceptrics-account-create', 'acceptricsCreateData', [ 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('acceptrics_create_account_nonce'), 'telemetryNonce' => wp_create_nonce('acceptrics_telemetry_nonce'), ] ); } add_action('admin_enqueue_scripts', 'acceptrics_enqueue_relay_scripts'); // --------------------------------------------------------------------------- // Settings page // --------------------------------------------------------------------------- function acceptrics_settings_page() { $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'settings'; $is_consent_api_active = acceptrics_is_wp_consent_api_active(); $account_id = get_option('acceptrics_account_id', ''); $enable_banner = get_option('acceptrics_enable_banner', false); $geo_area = get_option('acceptrics_geo_area', ''); $site_host_display = wp_parse_url(home_url(), PHP_URL_HOST); $plugin_install_url = admin_url('plugin-install.php?s=WP+Consent+API&tab=search&type=term'); $geoip_active = function_exists('geoip_detect2_get_info_from_current_ip'); $geoip_install_url = current_user_can('install_plugins') ? wp_nonce_url(admin_url('update.php?action=install-plugin&plugin=geoip-detect'), 'install-plugin_geoip-detect') : admin_url('plugin-install.php?s=geoip+detect&tab=search&type=term'); $wizard_url = 'https://acceptrics.com/wizard'; // Relay state data (for PHP-rendered active/dns views) $relay_state = acceptrics_relay_get_wizard_state(); $relay_tag_id = get_option('acceptrics_relay_tag_id', ''); $relay_hostname = get_option('acceptrics_relay_hostname', ''); $relay_cf_domain = get_option('acceptrics_relay_cf_domain', ''); $relay_cert_short = get_option('acceptrics_relay_cert_name_short', ''); $relay_cert_val = get_option('acceptrics_relay_cert_value', ''); $relay_subdomain = get_option('acceptrics_relay_hostname_short', 't'); $relay_activated_at = get_option('acceptrics_relay_activated_at', ''); $relay_meas_path = get_option('acceptrics_relay_measurement_path', '/t'); $relay_tag_ids = get_option('acceptrics_relay_tag_ids', []); if (empty($relay_tag_ids) && !empty($relay_tag_id)) { $relay_tag_ids = [$relay_tag_id]; } $site_domain = function_exists('acceptrics_get_site_domain') ? acceptrics_get_site_domain() : ''; $token_connected = !empty(get_option('acceptrics_api_token', '')); // Blocker detection settings + report stats $detect_enabled = (bool) get_option('acceptrics_blocker_detect_enabled', false); $consent_mode_enabled = (bool) get_option('acceptrics_consent_mode_enabled', true); $detect_stats = (array) get_option('acceptrics_detect_daily', []); krsort($detect_stats); $detect_recent = array_slice($detect_stats, 0, 7, true); $det_total_b = 0; $det_total_u = 0; foreach ($detect_recent as $_d) { $det_total_b += $_d['blocked']; $det_total_u += $_d['unblocked']; } $det_total_sampled = $det_total_b + $det_total_u; $det_blocker_pct = $det_total_sampled > 0 ? round(($det_total_b / $det_total_sampled) * 100) : null; $det_days = count($detect_recent); $det_avg_b = ($det_days > 0) ? round(($det_total_b / $det_days) * 10) : null; // Format activated date for display $relay_activated_display = ''; if ($relay_activated_at) { $ts = strtotime($relay_activated_at); $relay_activated_display = $ts ? date_i18n('M j, Y', $ts) : ''; } ?>
Acceptrics

Acceptrics Consent Banner

Share anonymous usage data? Help improve this plugin by sending product events — activation, setup steps completed, WordPress/PHP version, and your site domain — to Acceptrics analytics. Never anything about your visitors. Privacy Policy

New to Acceptrics? Create your free account

Create an account right here — your banner code is generated and saved automatically, and the consent banner goes live on your site. Free up to 50,000 page views/month, no credit card required.

By creating an account you agree to the Terms of Service and Privacy Policy. Your banner code will also be emailed to you. You can customize the banner anytime at acceptrics.com.

Account Code

Enter the account code from your Acceptrics account. This enables your consent banner on every page of your site.

<script async src="https://acct.acceptrics.com/"></script>

This script is injected into the <head> of every page on your site.

Don't have an account yet? Create one in the card above, or sign up at acceptrics.com/wizard.

Status

Consent banner
Live on for EU/EEA visitors. Browsing from outside the EU, you may not see it yourself. Live on for all visitors. Live on every page of . Not connected — create an account or enter your account code above.
Google Consent Mode
WP Consent API sync
WP Consent API plugin not installed — consent choices stay within Acceptrics. Installed, sync off — enable it below to share consent with other plugins. Syncing consent choices to other plugins.
Tag Relay (Analytics Recovery)
Active — see the Analytics Report tab for recovery data. Not active — optional; set it up in Analytics Recovery below.

Integrations

style="margin-top:2px;" />
Bridges your visitors' Acceptrics consent choices to the WP Consent API so other plugins can respect them. The banner itself is controlled by the account code above — it shows whenever a code is saved.
Bridges your visitors' Acceptrics consent choices to the WP Consent API so other plugins can respect them. Install the free WP Consent API plugin to enable syncing. The banner itself works without it.
Install Plugin
style="margin-top:2px;" />
Samples 10% of page loads to estimate how many visitors have ad blockers. Results appear in the Analytics Report tab. Adds ~1ms on sampled visits only.
Currently — product events only (setup steps, versions, site domain), never visitor data. Turn
style="margin-top:2px;" />
Sets consent defaults to denied before Google tags load, then updates when the visitor makes a choice. Disable only if you manage consent signals yourself and do not want Acceptrics to call gtag('consent', 'default', …).

Analytics Recovery

Beta

Recover analytics and conversion data lost to ad blockers and browser restrictions. Tags load through your own domain so they're indistinguishable from your site's own traffic. Learn more


1 How do you want to recover your analytics?

Both modes route your Google tags through your own domain, recovering data that ad blockers and browsers would otherwise block.

🌐
DNS Subdomain
Your tags load from a subdomain you own (e.g. t.), backed by a CDN. Requires two DNS records. Enables consent enforcement at the network layer.
CDN-backed — fastest $5/month
💻
Server Path
Tags load from a path on your own site (e.g. /metrics). No DNS changes needed — activate immediately and start recovering analytics today.
Zero DNS changes

2 Connect your Acceptrics account

Generate an API token in your Acceptrics dashboard under Account Settings → Developer API, then paste it here.

✓ API token connected

3 Configure your subdomain

Enter the Google Tag ID to route through your subdomain. We'll provision a CloudFront distribution and SSL certificate automatically.

Supports G-, GTM-, AW-, DC- prefixes. The first tag is the primary — the relay subdomain will be named after it. Find your ID in Google Analytics under Admin → Data Streams, or your container ID at tagmanager.google.com.

.

Your tags will load from t. (or your chosen subdomain).

2 Activate analytics recovery

No DNS changes or API token required. Choose a path on your site — tag requests route through your WordPress server so ad blockers and browser restrictions can't intercept them.

/

Your tags will load from /. Use any URL-safe path that isn't already taken by a page or post.

Supports G-, GTM-, AW-, DC- prefixes. Find your ID in Google Analytics under Admin → Data Streams, or your container ID at tagmanager.google.com.

ms

When your server is slow, analytics recovery automatically falls back to direct Google endpoints for up to 60 seconds, then retries.


GeoIP Detect  (optional plugin)
Forwards visitor country, region, and city to Google for accurate geo-targeting. Without it, Google uses only the visitor's IP address.
✓ Installed Install Plugin

✓ API token connected

4 Add two DNS records

Add both records to your DNS for . Analytics recovery activates automatically once the SSL certificate is issued (typically 5–30 minutes).

TypeNameValue
CNAME  
CNAME  

Some providers want just the subdomain part (e.g. _abc123.t); others want the full name with your domain appended. Try the short form first.

✅
Analytics Recovery active since
Analytics recovering via
Checking…
1) : ?>
Relay Paths
$_path) : ?>
→ https://
Relay URL
Tags
primary

GeoIP Detect (optional)
Forwards visitor location to Google for accurate geo-targeting.
Install Plugin
Routing Strategy
['label' => 'Adaptive', 'desc' => 'Browser probes Google directly; uses relay only when blocked. Reduces server load.', 'recommended' => true, 'warning' => false], 'always_relay' => ['label' => 'Always first-party relay', 'desc' => 'All tag traffic routes through your server. Maximum recovery, higher server load.', 'recommended' => false, 'warning' => false], 'always_direct' => ['label' => 'Always direct Google', 'desc' => 'Standard Google tags — relay disabled. Visitors with ad blockers will not be recovered.', 'recommended' => false, 'warning' => true], ]; foreach ($strategies as $key => $opt) : $is_selected = ($relay_strategy === $key); $is_warning = $opt['warning']; $border = $is_selected ? ($is_warning ? '#ef5350' : '#4CAF50') : ($is_warning ? '#ffcdd2' : '#e0e0e0'); $bg = $is_selected ? ($is_warning ? '#ffebee' : '#f1fbf1') : '#fff'; ?>

✅ Your tag 1 ? 's are' : ' is'; ?> deployed

1 ? 'are' : 'is'; ?> routing first-party through your server. Tag requests from your visitors bypass ad blockers and browser restrictions automatically — no snippet changes needed.


⚠ Setup failed

Analytics recovery could not be activated within 24 hours. This usually means one or both DNS records were not added correctly, or propagation timed out.

This report is about analytics recovery (Tag Relay): how many of your visitors block third-party analytics, and what routing tags through your own domain recovers. Your consent banner is not affected by ad blockers and isn't measured here — it works the same whether or not you use Tag Relay. Tag Relay is active on this site, so the numbers below include the traffic it recovers. Tag Relay is not active on this site — use blocker detection below to see how much analytics data you're losing and whether Analytics Recovery is worth enabling.

Blocker Detection

On 10% of page loads, fires a test request to googletagmanager.com to check whether your visitors can reach Google's analytics servers directly. If the request fails, that visitor likely has an ad blocker or browser restriction blocking third-party requests. Only the aggregate pass/fail count is stored — no visitor data is retained.

style="margin-top:2px;" />
Samples 10% of page loads. Adds ~1ms on sampled visits.
'margin-top:14px;']); ?>
0) : ?>

Analytics Uplift Estimate

%
of your visitors have an ad blocker or browser restriction
Based on estimated page loads ( sampled). With Analytics Recovery active, approximately events/day are being recovered that would otherwise be lost. Enable Analytics Recovery in Settings to start capturing these events.
$det_counts) : $det_b = intval($det_counts['blocked']); $det_u = intval($det_counts['unblocked']); $det_n = $det_b + $det_u; $det_pct = $det_n > 0 ? round(($det_b / $det_n) * 100) . '%' : '—'; ?>
Date Est. visitors Est. blocked Blocker rate

Estimates extrapolated ×10 from a 10% sample. Actual numbers may vary by ±15%.

📊
No data yet
Blocker detection is on. Data will appear here within a few hours of traffic. Enable blocker detection above to start collecting data.
0) : ?>

Adaptive Routing Stats

Sampled route decisions from the last 7 days (% sample rate). "Direct routed" means the browser could reach Google without the relay — no server load incurred.

$adp_row) : $d = intval($adp_row['direct'] ?? 0); $r = intval($adp_row['relay'] ?? 0); $n = $d + $r; $pct = $n > 0 ? round(($r / $n) * 100) . '%' : '—'; ?>
Date Direct Relay Relay rate

Sampled counts — actual totals are approximately × larger. Relay rate = share of loads where Google was unreachable and the relay stepped in.