How to install the ProfitWell.js Snippet for Retain

Overview

ProfitWell Retain needs you to add bit of JavaScript to your application so that it can display in-app notifications to your users, as well as overlay our payment forms on-top of your marketing site. Installation requires adding the snippet both on your marketing site, as well as inside your web-app (if applicable).

Instructions for platform specific instructions below:

Marketing Site

Retain reduces the friction of needing your users to sign into your app to update their payment information by overlaying the payment forms directly on your marketing site. You can pick any public facing marketing site —see Meetup below.

Copy and paste this snippet of javascript on your site, making it available on as many pages of your site as possible (ideally, all of them). The ProfitWell snippet was designed to work asynchronously to not affect page load speed and to gracefully handle any errors to not affect the normal functioning of the page. 

<script id="profitwell-js" data-pw-auth="PUBLIC_API_TOKEN_HERE">
(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', {});
</script>
Remember to replace PUBLIC_API_TOKEN_HERE (in the first line) with your public API token.

Web-App

If the user is logged in, make sure you pass the user's email to the snippet.

<script id="profitwell-js" data-pw-auth="PUBLIC_API_TOKEN_HERE">
(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', { 'user_email': 'USER_EMAIL_HERE' });
</script>
Remember to replace PUBLIC_API_TOKEN_HERE (in the first line) with your public API token.
Remember to replace USER_EMAIL_HERE (at the bottom) with your customer email.
  • You can defer the call to profitwell('start', { 'user_email': 'USER_EMAIL_HERE' }); , in case your customer identity is loaded asynchronously.
  • Also, if there are multiple users under one user who is being billed, you can substitute user email with the user id from your data provider (e.g. Stripe customer ID). You will need to call profitwell('start', { 'user_id': 'PROVIDER_USER_ID_HERE' }); instead of profitwell('start', { 'user_email': 'USER_EMAIL_HERE' });
    Remember to replace PROVIDER_USER_ID_HERE with the customer ID from your data provider (e.g. Stripe customer ID).


How did we do?


Powered by HelpDocs