Install Muro on WordPress
Add the Muro script to a WordPress site with a header code plugin, or from your child theme.
On WordPress, the easiest way to add the Muro script is a plugin that inserts code into the <head> of every page. It survives theme updates and works with any theme, including block themes. If you'd rather not add a plugin, you can add it from a child theme.
Steps
Copy your snippet
In Muro, go to Settings → Project → Tracking script and click Copy script:
<script async src="https://api.muroanalytics.com/muro.js" data-project-id="YOUR_PROJECT_ID"></script>Add it to the head of every page
- In WordPress admin, go to Plugins → Add New Plugin, search for WPCode, then install and activate it.
- Go to Code Snippets → Header & Footer.
- Paste the snippet into the Header box.
- Click Save Changes.
Other header plugins work the same way, for example Insert Headers and Footers or Header Footer Code Manager. Use the one you already have.
Add this to your child theme's functions.php. It prints the script in <head> on every page and works with classic and block themes:
add_action( 'wp_head', function () {
echo '<script async src="https://api.muroanalytics.com/muro.js" data-project-id="YOUR_PROJECT_ID"></script>';
} );Use a child theme, not your main theme. Edits to a parent theme's files are wiped on the next theme update.
Clear your cache
If you use a caching plugin or your host caches pages, clear the cache so visitors get pages with the script.
Verify it works
- Open your site in a private window, so you see it as a logged-out visitor.
- Open DevTools, go to the Network tab, filter by
collectand reload. You should see aPOSTtocdn.muroanalytics.com/collectwith status202. - Or, in Muro, set the time picker to Live. Your visit appears within about 30 seconds.
If nothing arrives, view the page source and search for muro.js to check the script is in the <head>.
Good to know
- Optimization plugins can delay the script. Settings like "Delay JavaScript execution" (WP Rocket, LiteSpeed Cache and others) hold scripts back until the visitor interacts, so quick visits are never counted. Add
muro.jsto the plugin's exclusion list. Also exclude it from JavaScript combining or minifying. - WordPress.com. Installing plugins needs a WordPress.com plan that allows plugins.
- Your own visits count. Muro has no setting to exclude them. With the child theme option you can skip logged-in users by wrapping the
echoinif ( ! is_user_logged_in() ) { ... }. For staging copies of your site, see Keep staging and localhost out of your data.