How to add a survey to a WordPress site: with WPCode or functions.php
WordPress gives you two ways to put a script on every page: a plugin for header and footer code, or your theme’s functions.php. Either takes a few minutes. Then you can ask readers whether an article helped, or buyers how the order went.
The Tack team··5 min read
Short answer
To add a survey to a WordPress site, add the site in Tack with its address and copy the snippet. Install the free WPCode plugin, open Code Snippets → Header & Footer, paste the snippet into the Footer box and save. Open the site once and Tack verifies the install. If you prefer code, print the snippet from your child theme’s functions.php on the wp_footer hook.
On WordPress.com, plugins need a paid plan (as of November 2026). With a caching plugin, clear the cache after the change. Then create a Pin in Tack, for example a thumbs up or down under blog articles once someone has read most of the page.
On this page
Step 1: add the site in Tack with its exact address
In Tack open Settings → Sites and install, add a site and choose WordPress. Use the address WordPress shows under Settings → General → Site Address (URL), which is where visitors land. Tack keeps only the domain and needs https.
Every domain is its own site in Tack, with its own snippet key:
yourblog.wordpress.comand your own domain are two sites, and so arewww.example.comandexample.com.- A staging copy from your host has its own address. It also copies the snippet with the live site’s key, so add the staging address as a separate site and use its key there.
Step 2: put the snippet in the footer
This is the snippet, with your site’s key instead of the dots:
<script src="https://trytack.io/r/v1.js" data-site="pk_…" async></script>With the WPCode plugin
- Under Plugins → Add New Plugin search for WPCode, install and activate it. It is free and was formerly called Insert Headers and Footers (WordPress.org).
- Open Code Snippets → Header & Footer.
- Paste the snippet into Footer and save. WPCode prints that box just above the closing
</body>tag (WPCode docs).
In functions.php
If you would rather not add a plugin, print the snippet on the wp_footer hook, which themes call right before </body> (WordPress developer docs):
// functions.php of your child theme
add_action( 'wp_footer', function () {
echo '<script src="https://trytack.io/r/v1.js" data-site="pk_…" async></script>';
} );Put it in a child theme: changes to the parent theme’s functions.php are lost on its next update (Theme handbook). If you prefer wp_enqueue_script, pass the key in the URL, because WordPress prints only the address. The strategy option needs WordPress 6.3 or newer (WordPress developer docs):
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_script( 'tack', 'https://trytack.io/r/v1.js?site=pk_…', array(), null,
array( 'in_footer' => true, 'strategy' => 'async' ) );
} );Use one of the two ways, not both. On WordPress.com, installing plugins is available on the paid plans; a free site has to upgrade first (WordPress.com support, as of November 2026).
Step 3: clear the cache and open the site
WordPress has no publish step for this; the snippet is live once saved. A caching plugin or your host’s cache can still serve the old pages, so clear it, then open the site once. The site in Tack switches to Installed as soon as a page loads the snippet. If not, Check the install looks at the page and tells you why.
Your first Pin: did this article help?
Most WordPress sites have a blog or help pages, and you rarely know which articles actually answer the question. The template Did this article help? shows a thumbs up and down on addresses starting with your blog path, for example /blog/, once a reader has scrolled through 70% of the page. Whoever gives a thumbs down gets one more question: “What was missing?” It asks everyone who reads that far, and the same reader again after 7 days.
Running WooCommerce? Put Satisfaction after a purchase on the order confirmation page: a 1–5 rating, and with a low score, what to improve. A visitor sees at most one question per visit across your Pins, so the two do not pile up.
Common reasons the snippet does not load
- Cached pages. Clear the cache of your caching plugin, your host and any CDN after you add the snippet.
- Delayed or combined JavaScript. Optimisation plugins can hold scripts back. WP Rocket’s Delay JavaScript execution, for example, waits for the first mouse move, tap, scroll or key press (WP Rocket docs). Add
trytack.ioto the plugin’s exclusions so time and scroll conditions count from the start. - Wrong address. If Tack says the snippet runs on another address, it is often www against no www, or a staging copy. Use the suggested address only if visitors see it.
- Content Security Policy. Security plugins can send a CSP header. Allow
https://trytack.ioinscript-src,connect-srcandfont-src. - Cookie consent plugin. Pins show without consent but keep no visitor ID across visits. To make a Pin wait, turn on Show only after consent and call
window.tack?.consent()from the plugin’s accept event. If the plugin blocks scripts until consent, accept on your own visit before you verify. - Theme without wp_footer(). Rare, but then neither WPCode’s Footer box nor the hook prints anything. Use the Header box instead.
Usability tests use the same snippet
With the snippet in place you can also run Tests on the site: people get a link, do tasks such as “find the article on returns” and Tack checks whether they got there, asks how hard it was and shows where they clicked. The Can they find it? template suits a blog or help section well.
FAQ
How do I add a survey to my WordPress site?
Add the site in Tack and copy the snippet. Install the free WPCode plugin, open Code Snippets → Header & Footer, paste the snippet into the Footer box and save. Clear the cache and open the site once; Tack verifies the install. Then create a Pin from a template.
Can I add the script without a plugin?
Yes. Print the snippet from your child theme’s functions.php on the wp_footer hook, or load it with wp_enqueue_script and the key in the URL as ?site=. Use a child theme so a theme update does not remove it.
Does it work on WordPress.com?
Yes, on a paid plan. WordPress.com allows installing plugins on its paid plans; a free site has to upgrade first (as of November 2026). Add your wordpress.com address or your own domain as the site in Tack.
What does it cost?
One Test or one Pin costs one credit, and a credit is €8, less in bigger packs. No seats, no subscription, no minimum. Credits don’t expire. A new account comes with 1 credit to try it.
Sources
- WordPress.org: WPCode – Insert Headers and Footers
- WPCode docs: Using the global header and footer settings
- WordPress developer docs: wp_footer
- WordPress developer docs: wp_enqueue_script()
- WordPress Theme handbook: Child themes
- WordPress.com support: Plugins (as of November 2026)
- WP Rocket docs: Delay JavaScript execution