Melhore a contagem de cliques do 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 curtidas

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 curtidas

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 curtidas

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 curtidas

@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 curtidas

@dax Alguma ideia de por que essa configuração é necessária para que os selos de clique dos onebox apareçam? Poderia alterar isso no meu site, mas, para ser útil, teria que mudar a configuração em massa para mais de 7400 usuários, o que prefiro evitar, pois só causaria confusão.

2 curtidas

Eu também não sei por que você se daria ao trabalho, já que os cliques na caixa única não serão contados de qualquer forma, exceto para as poucas pessoas que clicam no link menos óbvio. Isso significa que, em vez de não exibir dados sobre quantas vezes foi clicado, você exibirá dados incorretos (artificialmente baixos), o que, na minha opinião, é muito pior.

1 curtida

Bom ponto — idealmente, a onebox também deveria contar os cliques em seu título.

4 curtidas

Criei um componente de tema para contar também os cliques em seu título.

3 curtidas

Isso realmente costumava funcionar. Os cliques do Onebox eram contabilizados em nosso site. Depois, em algum momento, parou de funcionar. Não me lembro exatamente quando, mas acho que foi há mais de um ano. Digo que isso é uma regressão, não uma solicitação de recurso real.

Você poderia detalhar exatamente o que seu componente faz, @evantill?

1 curtida

Parece ser um pouquinho de JavaScript que poderia ser simplesmente adicionado ao núcleo, assumindo que funcione.

Apenas um script simples que substitui um clique em uma URL dentro do onebox por um clique na URL do cabeçalho.

    // se o clique estiver dentro do corpo do onebox
    $('.onebox-body a').on('click.onebox-track-url', function(event) {      
      event.preventDefault(); // -> ignora o evento de clique dentro do onebox
      var headerUrl = $(event.target).closest('.onebox').find('header a'); // seleciona a URL do cabeçalho
      // clique na URL do cabeçalho em vez disso para atualizar o contador de rastreamento
      if (headerUrl.length > 0) {
        headerUrl[0].click(); // -> simula o clique na URL do cabeçalho
      }
    });
</script>
1 curtida

Parece que os links dentro do corpo do onebox não são rastreados por escolha:

isValidLink() retorna false se o link estiver em .onebox-body

1 curtida

Uma solução poderia ser adicionar uma nova configuração no onebox para habilitar o rastreamento em links dentro dos oneboxes e, nesse caso, adicionar a classe track-link aos links dentro dos oneboxes?

1 curtida

Não está claro para mim, neste tópico, se foi uma decisão intencional deixar de rastrear cliques em onebox ou se isso é apenas um bug para o qual você poderia criar um pull request.

3 curtidas

Seria correto descrever a correção proposta como esta?

“Se o link estiver no corpo de um onebox, encontre a URL do onebox. Se essa URL for a mesma do link, conte o clique. Caso contrário, ignore.”

4 curtidas

É mesmo possível que o onebox tenha um link nele além da URL que está sendo oneboxed? Eu não teria pensado isso.

Adicionei essa funcionalidade no commit abaixo

5 curtidas