Monitoring script
Install the monitoring script on your website to analyze visitor behavior and identify invalid traffic.
The Monitoring script is the core of Tapper's invalid traffic detection. It runs on every page of your website, analyzes visitor behavior in real time, and builds the invalid traffic lists your ad platforms use to exclude invalid traffic.
Installing through a tag manager? Your container must already be live on your website. Google Tag Manager and Tealium iQ both walk you through that setup when you first create one.
Step 1: Copy the script
Open Setup > Website
In the sidebar, open Setup, then Website. If your workspace has more than one protected entity, first pick the one for this website with the switcher under the workspace name. The Website row shows once the protected entity has a Google Ads, Meta Ads, TikTok Ads or Microsoft Ads account connected. A workspace that uses Tapper Lift only has no Website row.
Open Monitoring
In the list of areas on the left, click Monitoring, then open the Install script and consent tab.
Copy the Monitoring script
The Monitoring script is the first section of the tab. Click the copy button in its code box. Then go to your tag manager (Google Tag Manager or Tealium iQ), or to your website's HTML for a manual install.
Step 2: Add the script
Create a new tag
In your GTM workspace, open Tags and click New.
Configure the tag
Select Custom HTML as the tag type and paste the copied monitoring script into the HTML field.
Set the trigger
Under Triggering, select the built-in trigger Initialization - All Pages, so the script fires early on every page.
Save the tag
Give the tag a name you will recognize, for example Tapper Monitoring Script, and click Save.
Publish
Click Submit, enter a version name and description, then click Publish.
Content security policy
If your website sends a Content-Security-Policy header, the browser refuses anything the policy does not name. The monitoring script then fails silently: nothing errors on your side and Tapper receives no visits. Some platforms enforce a policy by default: Magento 2.4.7 and later enforces one on the checkout page (the rest of a Magento storefront is report-only unless you change it). Add the entries below before you install.
Tapper shows the required entries under the monitoring script, in a box headed Content Security Policy, with its own copy button.
The list
This is the list Tapper tests in a real browser. Each line is a directive, a source and whether you need it. The table under it says what each entry is for.
script-src https://monitor.tapper.ai REQUIRED
connect-src https://protect.tapper.ai REQUIRED
connect-src https://fingerprint.tapper.ai REQUIRED
img-src https://protect.tapper.ai REQUIRED
worker-src blob: REQUIRED
connect-src https://m1.openfpcdn.io OPTIONAL
script-src 'unsafe-inline' CONDITIONAL
script-src https://www.googletagmanager.com CONDITIONAL| Entry | Needed | What breaks without it |
|---|---|---|
script-src https:// | Required. | Nothing runs. No events, no fingerprints, no conversions. |
connect-src https:// | Required. | Every call to Tapper is refused. The script loads and records nothing. |
connect-src https:// | Required. | The network fingerprint is never sent, so a bot signal is lost on every visit. |
img-src https:// | Required. | The summary sent when a page closes is refused, and so is the fallback that delivers events when an ad blocker stops the normal request. |
worker-src blob: | Required. | Part of the browser fingerprint (the part read from a Worker) is missing, and your CSP report endpoint receives a violation each time. |
connect-src https:// | Optional. | Nothing of Tapper's. An anonymous statistics request from a fingerprint library, about 1 page load in 1,000. We recommend you leave it out. |
script-src 'unsafe-inline' | Only with Tapper audiences. | The audience snippet from your ad platform does not run, so visitors are not added to the audience. |
script-src https:// | Only with Google Ads audiences. | The Google Ads snippet's gtag.js loader is refused, so visitors are not added to the audience. |
About 'unsafe-inline': it weakens your policy's protection against injected scripts, and browsers ignore it when script-src also has a nonce, a hash or 'strict-dynamic'. On such a policy audiences cannot run, even with the entry added.
The audience entries cover only what Tapper injects. The ad platform's own script then calls its own hosts; follow Google's and Meta's CSP guidance for those. A site that already runs their ad tags already allows them.
Where each entry goes
- Add each source to the matching directive already in your policy. Do not paste the lines in as new directives, and do not send a second
Content-Security-Policyheader: browsers ignore a repeated directive, and a second header blocks everything it does not list. worker-src blob:: if your policy has noworker-srcbut haschild-src, addblob:tochild-src. If it has neither, addblob:toscript-src, or add aworker-srcdirective that also keeps the sources your own workers need. Note thatblob:inscript-srcalso letsblob:scripts run.script-srcentries: if your policy also setsscript-src-elem, add them there too.connect-srcandimg-src: if the directive is missing, the browser usesdefault-src, so add the host there, or add the directive and repeat yourdefault-srcsources in it. A new directive stopsdefault-srcfrom applying, and your own requests would break.- Nonce policies with
'strict-dynamic'ignore host lists inscript-src. The script then loads only if whatever inserts it is trusted, for example GTM loaded with your nonce. - Trusted Types (
require-trusted-types-for 'script') is not supported.
Inline code and Google Tag Manager
The list assumes no inline code of Tapper's runs on your page. The monitoring script you copy from Tapper is an inline <script> block, and so is a GTM Custom HTML tag. Under a policy without 'unsafe-inline' in script-src, the browser refuses that block and the monitoring script is never even requested, whichever hosts you added. Pick one of these options:
- Your own script file, the option we recommend. Save the body of the snippet (the code between
<script>and</script>) as a file on your own site, for example/js/tapper.js, and load it with<script src="/. Your policy already allows your own origin (js/ tapper.js"></ script> 'self'), so there is nothing to add beyond the list. - A nonce, on a manual HTML install only. Add your per-response
nonceto the snippet's<script>tag. A GTM Custom HTML tag cannot carry a per-response nonce. - A hash. Add the block's
'sha256-...'hash toscript-src. The hash differs for every protected entity and changes if the block is edited at all.
The Tealium install is not affected: its extension code runs inside utag.js, not as an inline block.
Allowing https://www.googletagmanager.com lets the GTM container load. It does not allow the scripts GTM then injects: each of those still needs its own host in the policy (here https://monitor.tapper.ai), and inline Custom HTML tags need one of the options above.
Example header
Content-Security-Policy: script-src 'self' https://monitor.tapper.ai; connect-src 'self' https://protect.tapper.ai https://fingerprint.tapper.ai; img-src 'self' https://protect.tapper.ai; worker-src 'self' blob:Merge these sources into your existing directives. Do not replace your policy with this line.
Magento
With Magento_Csp, add an etc/csp_whitelist.xml file to one of your modules:
<?xml version="1.0"?>
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp:etc/csp_whitelist.xsd">
<policies>
<policy id="script-src">
<values>
<value id="tapper-monitor" type="host">https://monitor.tapper.ai</value>
</values>
</policy>
<policy id="connect-src">
<values>
<value id="tapper-protect" type="host">https://protect.tapper.ai</value>
<value id="tapper-fingerprint" type="host">https://fingerprint.tapper.ai</value>
</values>
</policy>
<policy id="img-src">
<values>
<value id="tapper-protect-img" type="host">https://protect.tapper.ai</value>
</values>
</policy>
</policies>
</csp_whitelist>Then run bin/magento cache:flush.
- Worker entry: do not add a
worker-srcpolicy. Magento sets noworker-src, and its defaultchild-srcalready allowsblob:, so the worker passes. Aworker-srcpolicy would block your store's own workers. If your store removedblob:fromchild-src, restore the blob scheme undercsp/in your config.policies/ storefront/ children/ schemes - Inline snippet: where the policy is enforced, allow the snippet by its hash inside the
script-srcpolicy, or use one of the other options above.
<value id="tapper-snippet" type="hash" algorithm="sha256">BASE64_HASH_OF_THE_SNIPPET_BODY</value>- Audiences:
csp_whitelist.xmlaccepts only hosts and hashes, so it cannot add'unsafe-inline'. Magento 2.4.7 and later also turns off inline scripts on the checkout page on purpose, so Tapper audiences cannot run there.
Step 3: Verify
Use GTM's Preview mode to confirm the tag fires on the pages of your website.
Next steps
- Install the conversion script on your confirmation page, or list your conversion pages instead.
- Choose your cookie policy and pass on your visitors' consent: see Consent and cookies.