On this page
WordPress
Last updated
Install the vTilt snippet on a WordPress site with a header-and-footer code plugin — no theme file edits. Covers self-hosted WordPress and WordPress.com plans, then confirms the first event.
If your site runs on WordPress, you can install vTilt without touching your theme's files. You add a small plugin that puts code in the head of every page, paste the snippet the dashboard gives you, and save.
#Before you start
- You can sign in to your WordPress dashboard as an administrator, so you can install plugins.
- WordPress.com sites only: adding plugins and adding code to the head need a paid plan. WordPress.com lists the Personal, Premium, Business and Commerce plans. A free WordPress.com site has to upgrade first. Self-hosted WordPress (from wordpress.org) has no such limit.
- You have your vTilt snippet. Copy it from Get started → Paste the snippet, or from Settings → Project → Installation. Your project token is already filled in there.
Why a plugin and not the theme? You could paste the snippet into your theme's header.php, but WordPress replaces theme files when the theme updates, and the snippet would disappear. A plugin keeps it safe across theme updates and theme switches.
#1. Install a header-and-footer plugin
These steps use WPCode (listed in the plugin directory as "WPCode – Insert Headers and Footers"), which is free and installed on millions of sites. Any similar plugin that adds code to the site header works the same way.
- In your WordPress dashboard, open Plugins and click the button to add a new plugin. Depending on your version it reads Add New, Add New Plugin or Add Plugin.
- Search for
WPCode. - Click Install Now on "WPCode – Insert Headers and Footers".
- Click Activate.
#2. Paste the snippet
- In the dashboard menu, open Code Snippets → Header & Footer.
- Paste your snippet into the Header box.
- Click Save Changes.
The code in the Header box is added to the head of every page of your site.
The snippet looks like this:
<script>
!function(t,e){var o,n,p,r;function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}if(!e.__SV&&!(window.vt&&window.vt.__loaded)){window.vt=e,e._i=[],o="init capture identify setUserProperties resetUser getUserIdentity getDeviceId getUserState alias getConfig getSessionId updateConfig setConsent on once off startAutocapture stopAutocapture startSessionRecording stopSessionRecording openChat closeChat toggleChat showChat hideChat sendChatMessage gtag setGoogleUserData".split(" ");for(n=0;n<o.length;n++)g(e,o[n]);e.init=function(i,s,a){(p=t.createElement("script")).type="text/javascript",p.crossOrigin="anonymous",p.async=!0,p.src=s.script_host?s.script_host+"/array.js":s.api_host+"/dist/array.js",p.onerror=function(){console.error("vTilt: Failed to load library script:",p.src)},(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="vt",u.toString=function(t){var e="vt";return"vt"!==a&&(e+="."+a),t||(e+=" (stub)"),e},n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1}}(document,window.vt||[]);
vt.init('YOUR_PROJECT_TOKEN', {
api_host: 'https://www.vtilt.com',
});
</script>#3. Confirm the first event
- Open your live site in a new tab and load any page.
- Go back to Get started in vTilt. It is waiting for your first event and switches to your dashboard by itself when the event arrives. This normally takes a few seconds.
To watch events arrive one by one, open the Debug View — see Verify events.
#If nothing arrives
#A caching plugin serves the old page
Caching plugins and host caches keep a saved copy of each page, so visitors may get a copy from before you added the snippet. Clear the cache in your caching plugin (or in your host's dashboard), then load the site again. WPCode tries to clear the cache of popular caching plugins when you save, but not every cache.
#The plugin is not active
Open Plugins and check that WPCode is listed as active. If you use a different header plugin, check that the snippet is saved in its header field, not in a single page or post.
#An ad blocker is in the way
Ad blockers can block analytics scripts. Test in a private window with extensions turned off. For visitors, a reverse proxy keeps vTilt's requests from being blocked.
#The token does not match
Check that the token in the snippet is the one shown for this project in Settings → Project → Installation. See Common mistakes.