Site builder integration
Session Replay for WordPress Sites
Add AnyReplay session replay to WordPress with the plugin from WordPress.org or a script tag, then mask personal data and confirm it records.
Updated · 5 min read
To add WordPress session replay with AnyReplay, install the AnyReplay plugin from the WordPress.org plugin directory and paste your project key under Settings → AnyReplay. There is no code to edit, and a script tag does the same job without a plugin. Every visitor session is recorded, and what visitors type into form fields is masked by default.
Why record sessions on your WordPress site
Page views and bounce rates say that visitors left, not why. WordPress session recording lets you watch the contact form that failed silently, the menu that did not open on a phone, or the pricing table people scrolled past twice. It is useful for blogs, business sites and WooCommerce shops alike, and it complements the analytics you already run. How to see what users do on your website explains where to start.
How to add session replay to WordPress
Install the plugin
In WordPress open Plugins → Add New, search for AnyReplay, then install and activate it. It is free on WordPress.org.
Paste your project key
Open Settings → AnyReplay, paste the key from your project's setup page and save. Nothing is recorded until then.
Visit your site
Open the site in a private window, because signed-in administrators are not recorded by default. The setup page switches to Connected when the first events arrive.
The plugin guide covers every setting and the hooks for developers.
Without the plugin: add the script tag
Where a plugin is not an option, paste the snippet yourself. Use one or the other, not both.
<script>
(function (w, d) {
w.anyreplay = w.anyreplay || function () {
(w.anyreplay.q = w.anyreplay.q || []).push(arguments);
};
var s = d.createElement('script');
s.async = 1;
s.src = 'https://cdn.anyreplay.com/v1/ar.min.js?k=YOUR_PROJECT_KEY';
d.head.appendChild(s);
})(window, document);
anyreplay('init', {
projectKey: 'YOUR_PROJECT_KEY',
ingestUrl: 'https://in.anyreplay.com',
// Stop recording after this many sessions in a calendar month.
// maxSessionsPerMonth: 10000,
// Form fields are masked: what visitors type replays as asterisks.
// Passwords, one-time codes and card fields are masked either way.
// Uncomment the first line to record what visitors type, or the
// second to hide rich-text editors too.
// maskAllInputs: false,
// maskAllTyping: true
});
</script>Option 1: a header scripts plugin
Install a header-scripts plugin such as WPCode, paste the snippet with your key into its site-wide header section and save. This survives theme changes.
Option 2: a child theme
Hook
wp_headin a child theme'sfunctions.phpand print the snippet, as in the example below. Edit the child theme, or a theme update will remove it.Option 3: Google Tag Manager
If GTM is already on the site, create a Custom HTML tag with the snippet and trigger it on All Pages, then publish the container.
add_action('wp_head', function () {
?>
<!-- Paste the AnyReplay snippet from your project's setup page here -->
<?php
});Caching and optimisation plugins that delay, defer or combine JavaScript can hold the snippet back or break its queue. If the setup page stays on waiting, exclude the snippet from those features and clear the cache. Sites on WordPress.com may not be able to add plugins or custom code on every plan; check their help centre. The script tag guide covers the snippet line by line.
Which pages are recorded (and which are not)
Every front-end page that prints the header is recorded: posts, pages, archives, search results and, on WooCommerce, product, cart and checkout pages rendered by your theme. The admin area under /wp-admin is not recorded. Pages built outside the theme, such as a separate landing page tool, need the snippet added there too.
How do I keep customer data out of recordings?
By default every field value replays as asterisks of the same length. If you want comment and contact forms to replay as they were filled in, untick Mask form fields in the plugin, or add maskAllInputs: false to the init options of the snippet; on a site with WooCommerce checkout or account forms, the default is the safer choice. Some fields are masked whatever you set: passwords and one-time codes, payment card fields, any value of 13 to 19 digits that passes the card-number check, and a half-typed card number past its sixth digit. Email and telephone fields are not among them: they are ordinary fields, masked by default and recorded once you opt out. For personal data printed on the page, such as a name on an account page, add the CSS class ar-mask to that block; in the block editor you can set it under Advanced → Additional CSS class(es). Use ar-block to leave an element out of the recording altogether. See masking.
Consent banners on WordPress
In the plugin, turn on Wait for consent: a consent plugin that supports the WP Consent API then starts and stops recording with the statistics category. With the script tag, add requireConsent: true to the init options and AnyReplay records and sends nothing until anyreplay('consent', true) runs. AnyReplay does not store the choice, so call it on every page load for visitors who already agreed. Most consent plugins offer a callback or an event for this. See consent and session replay and cookie consent.
Allowed domains
If your project lists allowed domains, AnyReplay checks each request's Origin header against them. Add your live domain, and your staging domain as well if the snippet runs there.
How do I check it is working?
- The project's setup page switches to Connected after the first accepted event.
- In the browser's network panel, requests to
in.anyreplay.comshould be answered with202. - Add
debug: trueto theinitoptions to log in the console why the recorder is not recording. - If a security plugin sends a Content Security Policy, allow the AnyReplay hosts as described in Content Security Policy. Otherwise see no sessions.
Frequently asked questions
Is there a WordPress plugin for AnyReplay?
Yes. Search for AnyReplay under Plugins → Add New, activate it and paste your project key under Settings → AnyReplay. It loads the same script as the snippet.
Does AnyReplay record the WordPress admin area?
No. The recorder is added to front-end pages only, and the plugin also skips signed-in administrators there by default.
Does it work with WooCommerce?
Yes, on pages your theme renders, including product, cart and checkout pages. Field values replay as asterisks on those pages by default; add the ar-mask class to account details printed on the page. Payment card fields and passwords are never recorded, whatever you set.
Why does nothing show up after I installed it?
The most common causes are a caching or optimisation plugin delaying the script, a cache that still serves the old page, or an allowed domains list that does not include the domain you tested on.