Onebox クリック数の改善

If I put a link into my posts, I see how many people have clicked on the link. But if I put the link on one line, and it gets one-boxed, then I never see any count of the clicks.

This post describes the issue further:

There are two parts to the answer.

First, you must enable opening links in an external tab. (I don’t understand this, technically, as other links are counted without turning this option on.)

Second…

So, the main link people will click on will never be counted. Again, I don’t understand the technical difference between the links and why one would be counted and not the other.

Regardless of my lack of understanding of what’s going on technically, I’d love to see Onebox link clicks counted consistently.

「いいね!」 6

I have gone through all the settings in my Dashboard and I have no check boxes to enable opening links in an external tab… but the links do open in another tab already.
We have tried clicking on both the title of an article and the link itself - no counter for either.
Here’s a stickler… for a day or two, the counter suddenly worked, then stopped again. Nothing was changed at all. I’ve also asked a mod and several users if they see any link counts next to the links posted. None have seen them so I know it’s not just me being an Admin.
Like you, I would like to see the Onebox link clicks counted consistently.

Edit: I should point out for link posted after a blank space (so they don’t get Oneboxed), the counter works… just not for Onebox.

「いいね!」 2

I already enabled the setting last week, search for default other external links in new tab. This setting will be applied to all new users who have registered on your site after the site setting has been enabled. Old users can activate it from their profiles (in case we can bulk enable the setting even for old users via console).

I tried to click on the two oneboxes in the first two posts of this topic https://forum.nodders.net/t/2019-plastic-waste-and-recycling/167 and the count has increased from 0 to 1. It is possible that the user who did the test was an old user and did not enable the setting for external tab on the profile, or that the user tried to open the link in a new window directly by right-clicking on the link itself.

「いいね!」 3

That’s what probably is happening. I’ll inform everyone that they will have to make the change in their profile… as I. :wink: Thank you.

Also note that clicking links in your own post will not increment the counters…

「いいね!」 3

@dax, @codinghorror, I found out why the link counter was working for me and others on our forum. In _Preferences/Interface/Other, although I did have the Open all external links in another tab checked, I also had the Show counts on browser icon checked. Apparently the latter overrides the first box. I unchecked the Show counts on browser icon, saved, then checked a post… the counter showed up!

I also found one little nuance. When a user posts a link and OneBox tries and fails to OneBox it - leaving the link as is - the link click counter will not work if the link isn’t preceded with a blank space. I just edited a user’s post where this just occurred, adding the space, and the counter began showing. :wink:

「いいね!」 2

@dax 1-box のクリックバッジを表示するには、なぜこの設定が必要なのかについて、何かご意見はありますか?私のサイトでは変更できますが、実用的にするには 7400 人以上のユーザーに対して一括で設定を変更する必要があります。混乱を招くだけなので、できれば避けたいです。

「いいね!」 2

なぜわざわざやる必要があるのか私にもわかりません。なぜなら、最も目立たないリンクをクリックするごく少数の人を除き、ワンボックスのクリックはカウントされないからです。つまり、クリック回数のデータが表示されない代わりに、誤ったデータ(人為的に低い値)が表示されることになります。私としては、こちらの方がはるかに問題だと考えます。

「いいね!」 1

良いご指摘です。理想的には、ワンボックスのヘッドラインへのクリックもカウントされるべきです。

「いいね!」 4

見出しのクリック数もカウントするために、テーマコンポーネントを作成しました。

「いいね!」 3

以前は確かに機能していました。当時は Onebox のクリックが当サイト内でカウントされていました。その後、ある時点で機能しなくなったのですが、正確な時期は覚えていませんが、おそらく1年以上前だと思います。これは新機能のリクエストというより、リグレッション(後退)だと考えています。

@evantill さん、お使いのコンポーネントが具体的にどのような役割を果たしているのか、詳しく教えていただけますか?

「いいね!」 1

動作すれば、コアに単純に追加できる小さな JavaScript のようなものに見えます。

URL の中のクリックをヘッダーの URL のクリックに置き換えるだけの単純なスクリプトです。

    // onebox 本体内でのクリックの場合
    $('.onebox-body a').on('click.onebox-track-url', function(event){      
      event.preventDefault(); // onebox 内のクリックイベントを無視
      var headerUrl = $(event.target).closest('.onebox').find('header a'); // ヘッダーの URL を選択
      // トラッキングカウンターを更新するために代わりにヘッダーの URL をクリック
      if(headerUrl.length > 0){
        headerUrl[0].click(); // ヘッダー URL でのクリックをシミュレート
      }
      });
    });
</script>
「いいね!」 1

どうやら、onebox 本体内のリンクは選択によって追跡されていないようです:

isValidLink() はリンクが .onebox-body 内にある場合に false を返します

「いいね!」 1

解決策として、onebox 内のリンクの追跡を有効にする新しい設定を onebox に追加し、その場合、onebox 内のリンクに track-link クラスを追加するのはどうでしょうか?

「いいね!」 1

このスレッドからは、ワンボックスのクリック追跡を停止することが意図的な決定だったのか、それとも単なるバグでプルリクエストを作成できるものなのか、明確ではありません。

「いいね!」 3

提案された修正を以下のように表現するのは正しいでしょうか?

「リンクが onebox 本文に含まれている場合、onebox の URL を取得します。その URL がリンクと同じであればクリックをカウントし、そうでなければ無視します」

「いいね!」 4

onebox 内に、onebox 対象の URL 以外のリンクを含めることは可能なのでしょうか?私はそうは思いませんでしたが。

この機能を以下のコミットで追加しました

「いいね!」 5