Installing the ProfitWell .js snippet with Wordpress and Memberpress

Follow the instructions below to install the ProfitWell .js snippet. You will need to install the snippet twice - once on your marketing site, and once within your web-app (a page your customer lands on after they log in).

  1. Download and install the "My Custom Functions" free plugin
  2. Add the following custom function and replace PUBLIC_API_TOKEN_HERE with your public API token:
function add_profitwell_script_to_footer() {
$token = "PUBLIC_API_TOKEN_HERE";

$start_options = "{}";
$current_user = wp_get_current_user();
if ($current_user->exists()) {
$start_options = "{user_email: '{$current_user->user_email}'}";
}

echo "
<script id='profitwell-js​' data-pw-auth='$token'>
(function(i,s,o,g,r,a,m){i[o]=i[o]||function(){(i[o].q=i[o].q||[]).push(arguments)};
a=s.createElement(g);m=s.getElementsByTagName(g)[0];a.async=1​;a.src=r+'?auth='+
s.getElementById(o+'-js').getAttribute('data-pw-auth');m.parentNode.insertBefore(a,m);
})(window,document,​'profitwell'​,​'script'​,​​'https://public.profitwell.com/js/profitwell.js');

​ ​ profitwell('start', $start_options);
​ ​</script>
";
}
add_action('wp_footer', 'add_profitwell_script_to_footer');

Referrer Policy

The Referrer-Policy HTTP header controls how much referrer information (sent via the Referrer header) should be included with requests. Aside from the HTTP header, you can set this policy in HTML.

For the ProfitWell snippet to work correctly, you must set the referrer policy to strict-origin.

You can set referrer policies inside HTML. For example, you can set the referrer policy for the entire document with a <meta> element with a name of referrer: <meta name="referrer" content="strict-origin">


How did we do?


Powered by HelpDocs (opens in a new tab)