'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) : ''; } ?>
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
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.
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
Both modes route your Google tags through your own domain, recovering data that ad blockers and browsers would otherwise block.
t.), backed by a
CDN. Requires two DNS records. Enables consent enforcement at the network layer.
/metrics).
No DNS changes needed — activate immediately and start recovering analytics today.
Generate an API token in your Acceptrics dashboard under Account Settings → Developer API, then paste it here.
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).
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.
When your server is slow, analytics recovery automatically falls back to direct Google endpoints for up to 60 seconds, then retries.
Add both records to your DNS for . Analytics recovery activates automatically once the SSL certificate is issued (typically 5–30 minutes).
| Type | Name | Value | |
|---|---|---|---|
| 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.
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.
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.
| Date | Est. visitors | Est. blocked | Blocker rate |
|---|---|---|---|
Estimates extrapolated ×10 from a 10% sample. Actual numbers may vary by ±15%.
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.
| 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.