Améliorer le comptage des clics 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 « J'aime »

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 « J'aime »

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 « J'aime »

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 « J'aime »

@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 « J'aime »

@dax As-tu des idées sur la raison pour laquelle ce paramètre est requis pour l’affichage des badges de clic des onebox ? Je pourrais le modifier pour mon site, mais pour qu’il soit utile, je devrais le modifier en masse pour plus de 7 400 utilisateurs, ce que je préfère éviter car cela ne ferait qu’ajouter de la confusion.

2 « J'aime »

Je ne sais pas non plus pourquoi tu te donnerais cette peine, puisque les clics sur la seule boîte ne seront pas comptabilisés de toute façon, sauf pour les quelques personnes qui cliquent sur le lien le moins évident. Cela signifie qu’au lieu d’afficher aucune donnée sur le nombre de clics, tu afficheras des données incorrectes (artificiellement basses), ce qui est, à mon avis, beaucoup pire.

1 « J'aime »

Un bon point — idéalement, la onebox compterait également les clics sur son titre.

4 « J'aime »

J’ai créé un composant de thème afin de compter également les clics sur son titre.

3 « J'aime »

Cela fonctionnait vraiment avant. Les clics Onebox étaient comptabilisés sur notre site. Puis, à un moment donné, cela a cessé de fonctionner. Je ne me souviens pas exactement quand, mais je pense que cela fait plus d’un an. Je dirais qu’il s’agit d’une régression, et non d’une véritable demande de fonctionnalité.

Pourriez-vous préciser exactement ce que fait votre composant, @evantill ?

1 « J'aime »

Cela ressemble à un tout petit bout de JavaScript qui pourrait simplement être ajouté au cœur, à condition que cela fonctionne.

Un simple script qui remplace un clic sur une URL à l’intérieur d’une onebox par un clic sur l’URL de l’en-tête.

    // si clic à l'intérieur du corps de la onebox
    $('.onebox-body a').on('click.onebox-track-url', function(event) {      
      event.preventDefault(); // -> ignorer l'événement de clic à l'intérieur de la onebox
      var headerUrl = $(event.target).closest('.onebox').find('header a'); // sélectionner l'URL de l'en-tête
      // cliquer à la place sur l'URL de l'en-tête pour mettre à jour le compteur de suivi
      if (headerUrl.length > 0) {
        headerUrl[0].click(); // -> simuler un clic sur l'URL de l'en-tête
      }
    });
</script>
1 « J'aime »

Il semble que les liens à l’intérieur du corps d’une onebox ne soient pas suivis par choix :

isValidLink() retourne false si le lien se trouve dans .onebox-body

1 « J'aime »

Une solution consisterait à ajouter un nouveau paramètre dans onebox pour activer le suivi des liens à l’intérieur des oneboxes et, dans ce cas, ajouter la classe track-link aux liens contenus dans les oneboxes ?

1 « J'aime »

Il n’est pas clair pour moi, à partir de ce fil de discussion, s’il s’agit d’une décision délibérée de cesser de suivre les clics sur les onebox ou si c’est simplement un bug pour lequel vous pourriez créer une pull request.

3 « J'aime »

Serait-il correct de décrire la correction proposée ainsi ?

“Si le lien se trouve dans le corps d’un onebox, trouvez l’URL du onebox. Si cette URL est identique au lien, comptez le clic. Sinon, ignorez-le.”

4 « J'aime »

Est-il même possible que la onebox contienne un lien autre que l’URL qui fait l’objet de la onebox ? Je ne l’aurais pas pensé.

J’ai ajouté cette fonctionnalité dans le commit ci-dessous

5 « J'aime »