Skip to main content

WordPress Implementation Guide

Multiple methods to implement DATA Reshape tracking on WordPress. Choose the one that fits your setup.

Prerequisites​

Required Before Implementation

Only implement after receiving confirmation that your custom domain and SSL certificate are active.

You will need:

  • Custom tracking subdomain (e.g. dre2.YOUR_DOMAIN.TLD)
  • Script ID provided by the DATA Reshape team
Implementation support — DATA Reshape can do this for you

You do not have to install everything by yourself. DATA Reshape provides hands-on implementation support and will perform the setup, audit, verification, and per-destination configuration on your WordPress site. To enable that, please create a dedicated Administrator account for us and email the credentials to [email protected].

  • Role: Administrator (required to edit theme files, manage plugins, and access caching / security settings).
  • Recommended: create a fresh user (e.g. datareshape) instead of sharing an existing one — easier to track activity and revoke.
  • Access can be revoked at any time once the installation and verification are confirmed live.

After access is granted, DATA Reshape will install the tracking code (theme / functions / plugin method, whichever is safest for your setup), audit and clean up duplicate destination code, adjust any conflicting caching/minification settings, and run the end-to-end verification — then report back when everything is live.

Enter your domain and everything below is written with it.

The fastest and safest install for WooCommerce stores — the official DATA Reshape plugin published on wordpress.org:

DATA Reshape for WooCommerce

What it does:

  • Injects the DATA Reshape tracking code on every front-end page (no theme edits, survives theme updates).
  • Auto-maps WooCommerce events — product viewed, add/remove to cart, checkout started, order placed, etc. — into the DATA Reshape event vocabulary, so most ecommerce events flow without any custom coding.
  • Reads the configured tracking subdomain and Script ID from a single settings page.

Install steps:

  1. In WordPress admin → Plugins → Add New → search DATA Reshape WooCommerce (or use the direct link).
  2. Click Install Now → Activate.
  3. Open the plugin's settings page → set Tracking subdomain (e.g. dre2.YOUR_DOMAIN.TLD) and Script ID → Save.
  4. Clear any caching plugins.

For non-WooCommerce WordPress sites, use one of the manual install methods below (Theme header, functions.php, child theme, or a generic headers-and-footers plugin). The events still need to be pushed from the page, but the tracking code itself loads exactly the same way.

Method 2: Theme header.php​

The most reliable manual method when the plugin doesn't apply — works across all WordPress configurations.

  1. Go to Appearance → Theme Editor → select header.php
  2. Add this code before the </head> tag:
<!-- DATA Reshape Tracking Code -->
<script>
(function(R,e,s,h,a,p,E){
var b=R.Reshape=R.Reshape||{};
b.setCookie=function(n,v,t,d){try{e.cookie=n+'='+v+';max-age='+t+';domain='+d+';path=/;SameSite=None;Secure';}catch(e){}};
b.id=a;b.cdn=h;b.sts=new Date().getTime();
E=e.getElementsByTagName(s)[0];p=e.createElement(s);p.async=true;p.src="https://"+h+"/main.js?id="+a;E.parentNode.insertBefore(p,E);
})(window,document,"script","dre2.YOUR_DOMAIN.TLD","YOUR_SCRIPT_ID");
</script>
<?php wp_head(); ?>
</head>
  1. Click Update File and clear any caching plugins
Theme Updates

Changes to theme files are lost during theme updates. Use a child theme or the functions.php method for persistence.

Method 3: functions.php​

Programmatic implementation via WordPress hooks. Add to the end of Appearance → Theme Editor → functions.php:

function add_data_reshape_tracking() {
$subdomain = 'dre2.YOUR_DOMAIN.TLD';
$script_id = 'YOUR_SCRIPT_ID';

if (!is_admin()) {
?>
<script>
(function(R,e,s,h,a,p,E){
var b=R.Reshape=R.Reshape||{};
b.setCookie=function(n,v,t,d){try{e.cookie=n+'='+v+';max-age='+t+';domain='+d+';path=/;SameSite=None;Secure';}catch(e){}};
b.id=a;b.cdn=h;b.sts=new Date().getTime();
E=e.getElementsByTagName(s)[0];p=e.createElement(s);p.async=true;p.src="https://"+h+"/main.js?id="+a;E.parentNode.insertBefore(p,E);
})(window,document,"script","<?php echo esc_js($subdomain); ?>","<?php echo esc_js($script_id); ?>");
</script>
<?php
}
}
add_action('wp_head', 'add_data_reshape_tracking');

Method 4: Insert Headers and Footers Plugin​

If you prefer not to edit theme files:

  1. Plugins → Add New → search "Insert Headers and Footers" → install and activate
  2. Settings → Insert Headers and Footers → paste in Scripts in Header:
<script>
(function(R,e,s,h,a,p,E){
var b=R.Reshape=R.Reshape||{};
b.setCookie=function(n,v,t,d){try{e.cookie=n+'='+v+';max-age='+t+';domain='+d+';path=/;SameSite=None;Secure';}catch(e){}};
b.id=a;b.cdn=h;b.sts=new Date().getTime();
E=e.getElementsByTagName(s)[0];p=e.createElement(s);p.async=true;p.src="https://"+h+"/main.js?id="+a;E.parentNode.insertBefore(p,E);
})(window,document,"script","dre2.YOUR_DOMAIN.TLD","YOUR_SCRIPT_ID");
</script>
  1. Click Save and clear cache

Method 5: Child Theme​

For persistence during theme updates. Create /wp-content/themes/your-child-theme/functions.php:

<?php
function add_data_reshape_tracking() {
if (!is_admin()) {
?>
<script>
(function(R,e,s,h,a,p,E){
var b=R.Reshape=R.Reshape||{};
b.setCookie=function(n,v,t,d){try{e.cookie=n+'='+v+';max-age='+t+';domain='+d+';path=/;SameSite=None;Secure';}catch(e){}};
b.id=a;b.cdn=h;b.sts=new Date().getTime();
E=e.getElementsByTagName(s)[0];p=e.createElement(s);p.async=true;p.src="https://"+h+"/main.js?id="+a;E.parentNode.insertBefore(p,E);
})(window,document,"script","dre2.YOUR_DOMAIN.TLD","YOUR_SCRIPT_ID");
</script>
<?php
}
}
add_action('wp_head', 'add_data_reshape_tracking');

Caching and Optimization Plugins​

The tracking code must never be delayed until user interaction

Several optimization plugins can hold JavaScript back until the visitor moves the mouse, scrolls or taps the screen (usually called Delay JavaScript). If the DATA Reshape code is delayed, visitors who leave without interacting are not measured at all — no page view, no session, no signal to the ad platforms — and visitors who do interact are measured late. Exclude the code from every "delay" feature. Plain defer or async loading is fine.

Add both of these strings to the exclusion lists below, one per line — the first matches the main.js file, the second matches the inline snippet:

dre2.YOUR_DOMAIN.TLD
Reshape
PluginWhereOfficial docs
WP RocketSettings → File Optimization → Delay JavaScript execution → Excluded JavaScript FilesDelay JavaScript execution · Troubleshoot Delay JS
WP Rocket (only if Combine JavaScript files is on)Settings → File Optimization → Excluded Inline JavaScriptExcluding inline JavaScript from combine
LiteSpeed Cache (when Load JS Deferred is set to Delayed)LiteSpeed Cache → Page Optimization → Tuning → JS Deferred / Delayed ExcludesPage Optimization
PerfmattersSettings → JavaScript → Delay JavaScript → Excluded from DelayDelay JavaScript
Cloudflare Rocket LoaderAdd data-cfasync="false" to the snippet's <script> tag: <script data-cfasync="false">Ignore JavaScripts in Rocket Loader
W3 Total CachePerformance → Minify → add the subdomain to the Never minify JS list—
WPEngineNo configuration needed—
WP Rocket shortcut

Instead of the exclusion lists, you can add the nowprocket attribute to the snippet's tag — <script nowprocket> — and WP Rocket will leave it untouched (Delay JavaScript execution).

After saving, clear the plugin cache and any CDN cache, then open the page source: the snippet must appear as a plain <script>, without type="rocketlazyloadscript" (WP Rocket), type="litespeed/javascript" (LiteSpeed Cache) or type="pmdelayedscript" (Perfmatters).

Verification​

End-to-end verification is performed by the DATA Reshape team. Reach out at [email protected] once the tracking code is installed, and we will run the confirmation tests, validate the data flowing to each connected destination, and confirm the configuration is correct.

Troubleshooting​

A few WordPress-specific install-time issues you can fix yourself:

SymptomLikely causeFix
Script not present in page sourcewp_head() is not called inside header.php, or the chosen install method does not run on the front endConfirm wp_head() is invoked in your theme's <head>, or switch to the Insert Headers and Footers plugin method.
Script loads on some pages onlyInstall method is template-specific (e.g. only single posts)Ensure the method runs on every page type (homepage, pages, posts, categories, products if WooCommerce).
Script suppressed after enabling a security or minification pluginPlugin conflictTemporarily deactivate security/minification plugins and confirm the script reappears; whitelist the subdomain in the plugin's configuration.
Script is in the page source, but tracking starts only after the first scroll / mouse move (and never for visitors who leave without interacting); the tag shows type="rocketlazyloadscript", type="litespeed/javascript" or type="pmdelayedscript"An optimization plugin delays JavaScript until user interactionExclude the code from the plugin's Delay JavaScript feature — see Caching and Optimization Plugins above.
Old script appears even after replacing the codePage or object cache still serves an older responseClear all caches (WP cache, CDN, browser) and re-test in incognito. See the Caching and Optimization Plugins table above.

For anything beyond install-time visibility — events that don't seem to arrive, deduplication concerns, destination-side discrepancies, or any other doubt about data quality — please contact [email protected]. By design, the only reliable view into event flow and destination delivery is the internal one; we'll confirm the state, identify the cause, and guide the fix.