For additional analytics and tracking outside of what is provided by default, you can embed third-party scripts in a variety of areas on the Thought Industries platform. You can track email captures, traffic data and much more.
Where do I find this?
Settings > Integrations > Tracking Scripts
How do I do this?
- From your homepage, select Settings.
- From the left menu, select Integrations, and then Tracking Scripts.
- From there, enter the appropriate scripts to any of the available fields.
- Click Save.
What else do I need to know?
Header Scripts
Header scripts are inserted before the "</head>" on every page. An example header script is:
<script type="text/javascript"> alert('Hello World'); </script>
Note that jQuery is already included on every page, so there's no need to include your own version, and doing so could cause conflicts.
Footer Scripts
Footer scripts are the most popular area to insert tracking scripts. We recommend putting all tracking scripts here if you are not sure where to put a tracking script. They are inserted before the "</body>" on every page. An example footer script is:
<script type="text/javascript"> alert('Hello World');</script>
If you are trying to change an element or add an element next to another one, you will have to wait for that element to be available before doing your next steps. This is because Thought Industries pages are built asynchronously, so not all elements are available on the page when it initially loads. Below is a sample script you can use for this purpose:
<script type="text/javascript"> var navBarTries = 0; function waitForNavBar() { if ($('.nav--top').length >= 1) { // do something with $('.nav--top') here } else { navBarTries = navBarTries + 1; if (navBarTries < 20) { setTimeout(waitForNavBar, 200); } } } waitForNavBar(); </script>
Order Confirmation Scripts
Order confirmation scripts are fired on the order confirmation page, after a successful order. The following substitutions are available:
{{totalInDollars}}
- total value of the order in dollars (e.g. 12.95)
{{totalInCents}}
- total value of the order in cents (e.g. 1295)
{{orderId}}
- the unique id of the order (e.g. 0c882527-a17a-40cf-bda1-161b180bde06)
An example order confirmation script is:
<script type="text/javascript"> alert('{{orderId}} was just purchased for a total of {{totalInDollars}}'); </script>
You also have access to window.orderItems, which contains a variety of details on everything that was ordered:
couponCode
- coupon code used (if any)
priceInCents
- price in cents of order item
purchasableType
- type of order item
purchasableId
- UUID of order item
quantity
- quantity of item ordered
total
- order item total
sku
- the SKU of the item ordered
title
- name of the product ordered
variationLabel
- the particular variation of the ordered item (if any)
An example order confirmation script that checks if the course with the slug "course-slug-here" was purchased is:
<script type="text/javascript"> window.orderItems.forEach(function(orderItem) { if (orderItem.slug === 'course-slug-here') { console.log('I am purchasing the specific course', orderItem); // insert any code you want to execute here } }); </script>
Finally, you have access to window.currentUser, which contains information about the user who purchased.
Email Capture Scripts
Email capture scripts are fired whenever an email is captured from a course waitlist or paywall. The following substitutions are available:
{{email}}
- email captured
{{source}}
- the source of the email capture, either "coursePaywall" or "courseWaitlist"
{{courseSlug}}
- the slug of the course the email was captured on
{{courseTitle}}
- the title of the course the email was captured on (because course titles can change, we recommend using the slug, sku, or ID)
{{courseSku}}
- the SKU of the course the email was captured on
{{courseId}}
- the ID of the course the email was captured on
An example email capture script is:
<script type="text/javascript"> alert('{{email}} captured from {{source}} on course {{courseSku}}'); </script>
Page View Scripts
Page view scripts are fired on page views on the public site and learner view. Does not fire on the following pages: sign in, sign out, forgot password, order confirmation, manager interface, and account management. The following substitutions are available:
{{url}}
- the url of the page viewed
{{email}}
- the email of the currently logged in user (if any)
{{role}}
- the role of the currently logged in user (if any)
{{firstName}}
- the first name of the currently logged in user (if any)
{{lastName}}
- the last name of the currently logged in user (if any)
{{userId}}
- the GUID of the currently logged in user (if any)
{{ref1}}, {{ref2}}, {{ref3}}
- the user's references codes (if any)
An example page view script is:
<script type="text/javascript"> alert('{{url}} viewed by {{email}} ({{role}})'); </script>
To fire a script when a specific URL is viewed, you can use a script like:
<script type="text/javascript"> if ('{{url}}' === 'URL_TO_THE_COURSE_PAGE_HERE') { alert('I am viewing the course'); // insert any code you want to execute here } </script>
Product View Scripts
Product view scripts are fired whenever a purchasable item (course, collection, etc.) is viewed. The following substitutions are available:
{{email}}
- the email of the currently logged in user (if any)
{{role}}
- the role of the currently logged in user (if any)
{{firstName}}
- the first name of the currently logged in user (if any)
{{lastName}}
- the last name of the currently logged in user (if any)
{{userId}}
- the GUID of the currently logged in user (if any)
{{ref1}}, {{ref2}}, {{ref3}}
- the user's references codes (if any)
{{purchasableType}}
- the type of the item viewed
{{purchasableTitle}}
- the title of the item viewed
{{purchasableSlug}}
- the slug of the item viewed
{{priceInCents}}
- the price (in cents) of the item viewed, e.g. 2499 for a $24.99 course.
{{priceInDollars}}
- the price (in dollars) of the item viewed
{{purchasableId}}
- the UUID of the item viewed
{{purchasableSku}}
- the SKU of the item viewed
An example product view script is:
<script type="text/javascript"> alert('{{purchasableTitle}} viewed by {{email}})'); </script>
Add Cart Item Scripts & Remove Cart Item Scripts
These scripts are fired when a cart item is added or removed. The following substitutions are available:
{{email}}
- the email of the currently logged in user (if any)
{{role}}
- the role of the currently logged in user (if any)
{{firstName}}
- the first name of the currently logged in user (if any)
{{lastName}}
- the last name of the currently logged in user (if any)
{{userId}}
- the GUID of the currently logged in user (if any)
{{ref1}}, {{ref2}}, {{ref3}}
- the user's references codes (if any)
{{purchasableType}}
- the type of the item added or removed from the cart
{{purchasableTitle}}
- the title of the item added or removed from the cart
{{purchasableSlug}}
- the slug of the item added or removed from the cart
{{priceInCents}}
- the price (in cents) of the item added or removed from the cart, e.g. 2499 for a $24.99 course.
{{priceInDollars}}
- the price (in dollars) of the item added or removed from the cart
{{purchasableId}}
- the UUID of the item added or removed from the cart
{{purchasableSku}}
- the SKU of the item added or removed from the cart
An example add cart item script is:
<script type="text/javascript"> alert('{{purchasableTitle}} added to the cart for {{priceInDollars}}'); </script>
Checkout Scripts - Step 1 & Step 2
These scripts are fired during the checkout flow, before a user completes a purchase. Step 1 is fired when the checkout flow is first entered, and step 2 is fired after collecting name/address information from the customer.
The following substitutions are available on the currently logged in user (if any):
{{userId}}
- the GUID of the currently logged in user (only available if the user was logged in at the start of the checkout flow)
{{email}}
- the email of the currently logged in user (if any)
{{role}}
- the role of the currently logged in user (if any)
{{firstName}}
- the first name of the currently logged in user (if any)
{{lastName}}
- the last name of the currently logged in user (if any)
{{userId}}
- the GUID of the currently logged in user (if any)
{{ref1}}, {{ref2}}, {{ref3}}
- the user's references codes (if any)
{{address1}}
- shipping address line 1
{{address2}}
- shipping address line 2
{{city}}
- the shipping city
{{state}}
- the shipping state
{{zipCode}}
- the shipping zip code
{{country}}
- the shipping country
The order is available on the window object, and can be manipulated with javascript window.order
-.The following keys are located on the order item:
gift
- true
or false
for whether or not an order is a gift
giftMessage
- the gift message (if any)
giftDeliveryDate
- date on which the gift will be delivered (if any)
giftRecipientEmail
- email address of gift recipient (if any)
giftRecipientFirstName
- first name of gift recipient (if any)
giftRecipientLastName
- last name of gift recipient (if any)
newsletterSignupChecked
- true
or false
for whether or not the user clicked to sign up for a newsletter
totalInCents
- price of order total in cents as a number
totalInDollars
- price of order total in dollars as a string
orderItems
- an array of order items, which have the following keys:
couponCode
- coupon code used (if any)
interval
- the interval at which a subscription is paid (if any)
needShippingAddress
- true
or false
for whether or not an order item needs a shipping address
priceInCents
- price in cents of order item
quantity
- number of item ordered
sku
- the SKU of the item ordered
taxable
- true
or false
for whether or not an order item is taxable
title
- name of the product
variationLabel
- the particular variation of the ordered item
weight
- how much the item weighs
The following example checkout script would create alerts for each order item:
<script type="text/javascript"> window.order.orderItems.forEach(function(orderItem){ alert(orderItem.title + ' was ordered by {{firstName}} {{lastName}}');}) </script>
Section Completed Scripts
These scripts are fired when a section is completed in the learner view. The following substitutions are available:
{{email}}
- the email of the currently logged in user (if any)
{{role}}
- the role of the currently logged in user (if any)
{{firstName}}
- the first name of the currently logged in user (if any)
{{lastName}}
- the last name of the currently logged in user (if any)
{{userId}}
- the GUID of the currently logged in user (if any)
{{ref1}}, {{ref2}}, {{ref3}}
- the user's references codes (if any)
{{sectionTitle}}
- the title of the section that was completed. Because section titles can change, we recommend using the slug.
{{sectionSlug}}
- the slug of the section that was completed
{{courseSlug}}
- the slug of the course the section was completed in
{{courseTitle}}
- the title of the course the section was completed in. Because course titles can change, we recommend using the slug, sku, or ID.
{{courseSku}}
- the SKU of the course the section was completed in
{{courseId}}
- the ID of the course the section was completed in
Course Completed Scripts
These scripts are fired when the course is completed in the learner view. The following substitutions are available:
{{email}}
- the email of the currently logged in user (if any)
{{role}}
- the role of the currently logged in user (if any)
{{firstName}}
- the first name of the currently logged in user (if any)
{{lastName}}
- the last name of the currently logged in user (if any)
{{userId}}
- the GUID of the currently logged in user (if any)
{{ref1}}, {{ref2}}, {{ref3}}
- the user's references codes (if any)
{{courseSlug}}
- the slug of the completed course
{{courseTitle}}
- the title of the completed course
{{courseSku}}
- the SKU of the completed course
{{courseId}}
- the ID of the completed course
What does this look like?
