How to install the ProfitWell.js Snippets

Overview

To use Retain, Term Optimization, or Reactivations, ProfitWell 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 forms on-top of your marketing site. The snippets needed are the same if you want to use any of these products- if you've already installed the snippets once, you will not need to install these snippets again. Initial installation requires adding the snippet both on your marketing site, as well as inside your web-app (if applicable).

Specific instructions for each platform below:

Marketing Site

The form we overlay on your marketing site looks different depending on the product. The same snippet will have a different form displayed depending on the user that is being targeted.

Retain Display

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.

Term Optimization Display

Term optimization allows users to upgrade their account with one simple click of a button without needing to sign into their account. Users who's plans are being targeted for upgrades will be able to view this display.

Reactivations Display

Reactivations does outreach to users who've churned to make it easier for them to reactivate their account by reducing the friction and giving them incentives.

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. 

You only need to install this marketing snippet on your marketing site. This snippet generates the no sign in form that users are directed to after they click on the link they receive in their emails- the marketing site that the snippet is installed on will serve as a backdrop.

<script id="profitwell-js" data-pw-auth="PUBLIC_API_TOKEN_HERE">
/* DO NOT DELETE - this code is used to accept our payments or send data to ProfitWell*/
(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>
Update PUBLIC_API_TOKEN_HERE (on Line 1) with your public API token. Please see bottom of page for instructions on retrieval.

Web-App

If the user is logged in, make sure you pass the user's email to the snippet. 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).

<script id="profitwell-js" data-pw-auth="PUBLIC_API_TOKEN_HERE">
/* DO NOT DELETE - this code is used to accept our payments or send data to ProfitWell*/
(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>
Update PUBLIC_API_TOKEN_HERE (on Line 1) with your public API token. Please see bottom of page for instructions on retrieval.

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.
  • You can substitute user email with the user id from your data provider (e.g. Stripe customer ID), which is helpful if: 1) there are multiple users under one user who is being billed 2) you don't have email info
    You will need to call profitwell('start', { 'user_id': 'PROVIDER_USER_ID_HERE' }); instead of profitwell('start', { 'user_email': 'USER_EMAIL_HERE' });

Do not use both user_email and user_id— Pick one one or the other.

Remember to replace PROVIDER_USER_ID_HERE with the customer ID from your data provider (e.g. Stripe customer ID).

How to test the installed snippets

Visit this page here to test the marketing snippets.

How to find public API token

Under "Account Settings" > "Integrations" > "API Keys/Dev Kit"

If you copy-paste the snippet directly from the Integrations page, then the public API token should be automatically loaded in for you already.


How did we do?


Powered by HelpDocs (opens in a new tab)