FastComments.com

Add Comments to ThriveCart Learn+ Courses


FastComments を使うと、任意の ThriveCart Learn+ コースにライブコメント機能を簡単に追加できます。

セットアップに問題がある場合は、FastComments のサポートが支援を提供できます。

このチュートリアルは FastComments アカウントを必要とすることに注意してください。まずサインアップしてからここに戻ってくることをおすすめします。 こちらからアカウントを作成できます。


ステップ 1: コースを準備する Internal Link

ThriveCart Learn+ の設計上、コメントを表示したい各コースページに FastComments のコードを追加する必要があります。

同じコードスニペットをすべてのページで使用でき、コメントスレッドは自動的に各ページごとに紐づけられます。

まず、コースをエディターで開き、HTML ブロックを追加します。

左側に HTML ブロックのオプションが表示されるはずです。コメントを表示したいページの位置へそのブロックをドラッグしてください。

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

新しく追加した HTML 要素を選択します。コードを貼り付けられるブロックが左側に表示されます。

これでステップ 2 の準備が整いました。

ステップ 2: カスタムコードを追加する 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+ コメントコード
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 if (url) {
67 url = url.replace('/starte-hier', '');
68 url = url.replace('/start-here', '');
69 }
70
71 FastCommentsUI(document.getElementById('fastcomments-widget'), {
72 tenantId: 'demo',
73 urlId: url,
74 simpleSSO: isAuthenticated ? simpleSSO : null
75 });
76 }
77
78 tryLoad();
79
80 function getPathnameFromUrl(url) {
81 try {
82 const parsedUrl = new URL(url);
83 // trim marketing parameters and domain name
84 return parsedUrl.pathname;
85 } catch (error) {
86 console.error("Invalid URL", url, error);
87 return window.location.pathname; // default to current, so at least it works sometimes
88 }
89 }
90
91 })();
92</script>
93

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

コードが追加されました
コードが追加されました

That's it! Now we just have to 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.

テストに関する注意!

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.

完了 Internal Link


成功しました!FastCommentsコメントウィジェットが表示されているはずです。

成功!
成功!

ThriveCartでFastCommentsを設定したことをおめでとうございます!ドメインエラーが発生した場合、またはコメントエリアをカスタマイズする方法を学びたい場合は、読み進めてください!


カスタマイズ Internal Link


FastComments はあなたのサイトに合わせてカスタマイズできるよう設計されています。

カスタムスタイリングを追加したり、設定を微調整したい場合は、カスタマイズに関するドキュメントをご覧ください。方法が記載されています。