Link click counters not working for 'open in new tab'?

We noticed that link counters won’t increase if you right-click on them and select ‘open in new tab’, or if you use the middle mouse button on them.

1 Like

That’s because it’s a browser function, there’s no click action to catch. AFAIK the destination page won’t see a referrer either, it’s akin to copy-pasting the URL into the address bar.

5 Likes

does the same issue happen for middle click or control click?

That makes sense, thanks!

It does. I included that in my post :slight_smile:

4 Likes

The <a ping> attribute could be used to increment the counter.

Caveats:

  • It’s disabled by default in Firefox.
  • there don’t seem to be any JS events for it, so the counter would only visibly be updated the next time the post was visited.

NB: It seems like “mousedown” events are triggered on middle click, but that would have false positives as not every click ends up being a navigation - eg. copy link, customised browser settings.

2 Likes

There is MouseEvent.button, which is 1 which is for “Auxiliary button pressed, usually the wheel button or the middle button (if present)”.

I think this is fine. I don’t think we want to count strictly the amount of times the linked page was loaded, rather just “link interactions”. I think “copy link” should also increase the counter, just as simply left clicking the link does.

In addition, I think most people don’t simply left-click such links: they usually want to open it in a new tab such that the original forum post is still open and they don’t have to navigate back and forth.