Skip to content

Instantly share code, notes, and snippets.

@kmclaugh
Last active November 1, 2021 15:29
Show Gist options
  • Save kmclaugh/6f257219819b36c16099efa3173050ba to your computer and use it in GitHub Desktop.
Save kmclaugh/6f257219819b36c16099efa3173050ba to your computer and use it in GitHub Desktop.
My Life Jars Datalayer

Below is the code that needs to be added when the user

Submits an email Logins in Signs up The {{variable}} templates need to be filled in with the actual values.

We will also have to add the gtm-container to the https://app-api.mylifejars.com/external/signup app and https://app.mylifejars.com/create-account

/*
* action: account upgrades
* description: fire whenever a user upgrades their account
*/
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "Account Upgraded",
properties: {
object: "Account",
action: "Upgraded",
user_id: "{{userId}}", // The user id
value: "{{price}}", // The monthly price of the plan
plan: "{{plan}}", // The plan name // My LifeJars Gold
payment_plan: "{{payment_plan}}", // the payment plan for the account // monthly, annual, one-time
stripe: {
subscription_id: "{{stripeSubscriptionId}}", // the stripe subscription id // sub_1Jie...
}
},
});
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PFKGLR6');</script>
<!-- End Google Tag Manager -->
/*
* action: sign ins
* description: fire whenever a returning user signs in (ie logins)
*/
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "User Signed In",
properties: {
object: "User",
action: "Signed In",
user_id: "{{userId}}", // The user id
email: "{{email}}", // The user's email address
first_name: "{{firstName}}", // the user's first name
last_name: "{{lastName}}", // the user's last name
},
});
/*
* action: sign ups
* description: fire whenever a new user signs up for the first time (ie creates an account)
*/
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: "User Signed Up",
properties: {
object: "User",
action: "Signed Up",
user_id: "{{userId}}", // The user id
email: "{{email}}", // The user's email address
first_name: "{{firstName}}", // the user's first name
last_name: "{{lastName}}", // the user's last name
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment