Overview
For this installation path, we expect you to have only one Google Tag Manager container for both your Marketing site and Web-app site. In this case, we recommend you install the snippet once but start with a different behavior based on which site the snippet is in.
- Marketing sites: users can't sign in to these sites, e.g. landing pages, marketing sites, promotional pages.
- Web-Apps: users can sign into them, although they may also be able to visit these sites anonymously, without an account.
It is recommended to first load the snippet and then, once your app knows exactly whether there is a logged-in customer or not, start it.
Load the snippet
- Click on New Tag and write a meaningful name, like
ProfitWell Snippet Load.
- On Tag Configuration, click on Custom HTML.
- Paste the ProfitWell snippet, replacing
PUBLIC_API_TOKEN_HERE
with your public API token.<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'); </script>
- Check Support document.write below the HTML snippet.
- On Triggering, select All Pages.
- Save the tag.
Start it
From within your page, you have to tell Google Tag Manager's Data Layer whether there is a logged-in customer or not, in other words, if you are in your Marketing site or your Web-app site.
- If there is a logged-in customer (In-app site):
dataLayer.push({ 'event': 'start_pw','pw_user_email': user_email})
- If you are sure that the customer is anonymous (Marketing site):
dataLayer.push({ 'event': 'start_pw' })
For more information on the Data Layer, visit the Google Tag Manager Developer Guide.
Then, on the corresponding Google Tag Manager container, ensure that the pw_user_email
variable is defined:
- Go to Variables and under User-Defined Variables, click on New and write
pw_user_email
as the name - On Variable Configuration, select Data Layer Variable
- Write
pw_user_email
as the Data Layer Variable Name and click on Save
After that, add the PW Start tag and publish:
- Click on New Tag and write a meaningful name, like
ProfitWell Snippet Start
- On Tag Configuration, click on Custom HTML
- Paste this snippet to start:
<script> profitwell('start', { 'user_email': {{pw_user_email}} }); </script>
Do not worry about anonymous customers, the above snippet will work for them, and also for those that are logged in. - On Triggering, click on + (New Trigger) and write a meaningful name, like
Start PW
- On Trigger Configuration, click on Custom Event
- In Event name, write
start_pw
(or whatever event name you pushed to the Data Layer.) - Save the trigger, Save the tag and Submit all the changes