FastComments.com

Add Comments to ThriveCart Learn+ Courses

With FastComments we can easily add live commenting to any ThriveCart Learn+ Course.

If you have any issues with the setup FastComments Support can also provide assistance.

Note that this tutorial requires a FastComments account. It's recommended that you sign up first and then come back here. You can create an account here.

Step 1: Prepare Course Internal Link

Due to the design of ThriveCart Learn+, we have to add the FastComments code to every course page we want to display comments on.

We can use the same code snippet on every page, and separate comment threads will automatically be tied to each individual page.

We'll start by opening our course in the editor and adding an HTML block.

On the left you should see an HTML block option. Drag that into the page where you want to display comments.

Open Course and Add HTML Block
Open Course and Add HTML Block

Now select the new HTML element. A block will appear on the left where we can paste our code.

Now you're ready for Step 2.

Step 2: Add Custom Code Internal Link

For Step 2 we have to copy our code snippet. Check that line 50 does not say "demo" - you'll want to ensure this has your tenant id. It should be populated for you.

Now let's copy our ThriveCart-Learn-Specific FastComments code snippet.

It's quite large, because the integration with ThriveCart has a lot of features, so just click the Copy button in the top right of the code snippet:

ThriveCart Learn+ Comments Code
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-v2.min.js"></script>
3<div id="fastcomments-widget"></div>
4<script>
5 (function () {
6 let attemptsRemaining = 10;
7
8 function tryLoad() {
9 const simpleSSO = {optedInNotifications: true, optedInSubscriptionNotifications: true};
10 let isAuthenticated = false;
11 let profileLink = document.querySelector('.thrivecart-courses-header-profile-link');
12 if (!profileLink) {
13 profileLink = document.querySelector('.thrivecart-courses-header-profile'); // class is different for preview.
14 }
15 // broad email input field selector incase ThriveCart changes id.
16 const emailInputField = document.querySelector('input[type=email]');
17 if (emailInputField && emailInputField.value) {
18 isAuthenticated = true;
19 simpleSSO.email = emailInputField.value;
20 } else if (profileLink && !profileLink.innerText.includes('John Smith')) { // allow preview to work - no email available.
21 attemptsRemaining--;
22 if (!attemptsRemaining) {
23 return console.error('Could not load FastComments - could not determine user information (email). Please reach out to FastComments support.');
24 }
25 console.warn('FastComments: No user email found - waiting and trying again.');
26 return setTimeout(tryLoad, attemptsRemaining < 5 ? 3000 : 100); // increase wait time after 5 attempts incase slow internet.
27 }
28 if (profileLink) {
29 // use raw "img" query incase ThriveCart changes image class selector.
30 const avatarImg = profileLink.querySelector('img');
31 if (avatarImg && avatarImg.src) {
32 isAuthenticated = true;
33 simpleSSO.avatar = avatarImg.src;
34 }
35 // use innerText incase ThriveCart changes how profile name is displayed.
36 if (profileLink.innerText) {
37 isAuthenticated = true;
38 simpleSSO.username = profileLink.innerText;
39 } else {
40 const bold = profileLink.querySelector('b');
41 if (bold && bold.innerText) {
42 isAuthenticated = true;
43 simpleSSO.username = bold.innerText;
44 }
45 }
46 } else {
47 if (!attemptsRemaining) {
48 return console.error('Could not load FastComments - could not determine user information (user name/avatar). Please reach out to FastComments support.');
49 }
50 console.warn('FastComments: No user profile info found - waiting and trying again.');
51 attemptsRemaining--;
52 return setTimeout(tryLoad, attemptsRemaining < 5 ? 3000 : 100); // increase wait time after 5 attempts incase slow internet.
53 }
54
55 let url;
56 const selectedNavLink = document.querySelector('.tcc-browse-lesson.active a');
57
58 if (selectedNavLink) {
59 // sometimes TC uses multiple links the same page, so let's de-dupe them.
60 url = getPathnameFromUrl(selectedNavLink.href);
61 } else {
62 // trim marketing parameters and domain name
63 url = window.location.pathname;
64 }
65
66 FastCommentsUI(document.getElementById('fastcomments-widget'), {
67 tenantId: 'demo',
68 urlId: url,
69 simpleSSO: isAuthenticated ? simpleSSO : null
70 });
71 }
72
73 tryLoad();
74
75 function getPathnameFromUrl(url) {
76 try {
77 const parsedUrl = new URL(url);
78 // trim marketing parameters and domain name
79 return parsedUrl.pathname;
80 } catch (error) {
81 console.error("Invalid URL", url, error);
82 return window.location.pathname; // default to current, so at least it works sometimes
83 }
84 }
85
86 })();
87</script>
88

Now paste it into the code block on the left in the ThriveCart editor. It should look like this:

Code Added
Code Added

That's it! Now we just have to publish:

Publish
Publish

That's it! You should now see the comment box on your course when you preview, and real users will be able to leave comments without signing in or leaving their username/email a second time.

Testing Note!

If you have anonymous commenting disabled, which it is by default, you won't be able to leave comments in Preview mode as the John Smith user. You will get an authentication error as the default John Smith user has no email. If you want to test, we suggest you use a coupon code and go through your site like an actual user.

Success Internal Link

Success! You should now see the FastComments Comment Widget.

Success!
Success!

Congratulations on setting up FastComments with ThriveCart! If you've run into a Domain Error, or would like to learn how to customize the comment area, read on!

Customization Internal Link

FastComments is designed to be customized to match your site.

If you'd like to add custom styling, or tweak configuration, Checkout our Customization Documentation to learn how.