Adding Web Analytics, Conversion Tracking, Completion Tracking or Custom Javascript

  • Updated

Add your own analytics and tracking systems to your Skilljar courses on the Theming page of your Skilljar dashboard. In this article, we'll cover topics such as cookie policy code snippets and global, conversion, and conversion tracking codes.

Adding analytics and tracking codes

You can add code snippets to your Skilljar dashboard using these steps:

  1. Open your Skilljar dashboard and select Themeing, or expand the Themeing header on the left and then select Themes
  2. Select the theme you want to manage from the list. 
  3. Scroll down and select the Code Snippets header to reveal the snippet fields. 
  4. Add your desired code snippets, and when you're finished, select Save and Continue or Save to apply them. 

Code Snippet fields

e2abacb9-4f7a-4000-8de4-a8110f5ac7e3.gif

  • Global Title - String input, which loads as Metadata in the <head> of every webpage on your training site.
  • Cookie Policy Code Snippet - Loads before the <head> on each webpage in your training site. This should only be used for cookie management tools that need to load before cookies can be set on your web pages. 
  • Analytics Tracking Code Snippet - Used for analytics tracking. You can still use the Global Head Snippet, but this field makes managing your analytics tracking code easier. 
  • Global Head snippet - Loads in the <head> on each webpage in your training site. This snippet is the best place for styling (CSS).
  • Global Code Snippet - Loads after the <body> of each webpage in your training site and is the best place for scripts (JS), which changes data that has loaded as a part of the page. 
  • Conversion Code Snippet - The code in this snippet runs after a learner purchases a course or enrolls in a free one. It's used for Javascript integrations that need to trigger when a student registers for a course. 
  • Course Completion Snippet - The code in this snippet runs after a learner has completed a course and is used for Javascript integrations that need to trigger when the learner has completed a course. 

Cookie policy code snippet

The Cookie Policy Code Snippet can be used to install Cookie Management Systems, which will load before the HEAD section of the webpage.

 

Screen_Shot_2020-09-30_at_2.08.57_PM.png

 

If you use tools such as OneTrust, Cookie Snippet, and Osano to load a Cookie Management System on your training domain, you can use this snippet location for those JavaScript tools.

Global Tracking Codes

To add the code to ALL pages, paste your snippet into the field titled "Global code snippet". Here are links to locate common snippets:

Conversion Tracking Codes

You can also add custom tracking to registrations. This is frequently used to track conversions from marketing campaigns or to send lead data to customer relationship management (CRM) systems. Just paste the snippet into the field titled 'Conversion code snippet'.

Please note that you may need to add <script> </script> tags around the snippet if they are not present by default. Here are links to locate common conversion tracking snippets:

Conversion Tracking Codes - Advanced Javascript

For advanced users, we include several Javascript variables within the page which you can use as optional parameters within your code snippets. Here are the variables we currently support. Please let us know if you would like to see additional fields tracked.

Note: The lesson parameter is only present within the skilljarCourse object when viewing a lesson page. To include lesson information in your tracking, you'll need to make sure it exists in the skilljarCourse object first. Additionally, the skilljarUser variable only exists when a user is signed into the system. Pageviews by unauthenticated users will not contain a skilljarUser variable.

var skilljarUser = {
    id: '2qd4gf6abc7d8',
    email: 'jane@example.com',
    name: 'Jane Doe',
firstName: 'Jane'
lastName: 'Doe' };
var skilljarCourse = { id: 'x24tgec3bed2', title: 'Your Course Title', tags: ["Tag name 1", "Example Tag 2", "Example Tag3"], lesson: { id: 'y35uhfd4cgf2e', title: 'Your Lesson Title' } };
var skilljarPurchase = { type: 'COURSE_ENROLLMENT', quantity: 1, orderId: '41X6G94W', currencyCode: 'USD', price: 25.00
};

If a user bulk-purchases a course, the skilljarPurchase's type attribute will be type: 'BULK_PURCHASE' and the quantity attribute will represent the number of registrations purchased.

If a user purchases access to a domain, the type attribute will be type: 'DOMAIN_ACCESS', with additional attributes such as 'domain'.

Browser and document Javascript objects are also supported, such as page URL.

An example Segment.io event might look as follows:

<script>
   analytics.track('Purchase', {
       course: skilljarCourse.title,
       pricepaid: skilljarPurchase.price
   });
</script>

Completion Tracking Codes

You can also add custom tracking to course completions. Just paste the snippet into the field titled 'Completion code snippet'.

The course completion code snippet is run by injecting it into the page that the student is on when a course is completed successfully. When the browser runs this javascript snippet, it has access to the skilljarUser, skilljarCourse, and skilljarCourseProgress variables on the page:

var skilljarUser = {
    id: '2qd4gf6abc7d8',
    email: 'jane@example.com',
    name: 'Jane Doe'
};

var skilljarCourse = { id: 'x24tgec3bed2', title: 'Your Course Title', tags: ["Tag name 1", "Example Tag 2", "Example Tag3"], lesson: { id: 'y35uhfd4cgf2e', title: 'Your Lesson Title' } };

var skilljarCourseProgress = { successStatus: 'PASSED' // or 'FAILED', can also be 'NULL' if there is no course score };

Note: The skilljarCourseProgress variable will show as PASSED or FAILED only if a lesson is set as the course score, other it will return as null.

Follow our Support guides for:

Was this article helpful?

0 out of 1 found this helpful