Click counter missing for some internal links

It seems likely that this has been discussed before but despite my excellent search skills, I was unable to find the answer to this question:

Why is there no click counter for internal links? Or rather: some internal links. Like this one or this one

edit: but what about a link without your username tracking in the URL, like this one?

Internal links that do get click counters seem to be:

  • Incoming links listed under posts
  • Links to tags, like this one.
3 Likes

Links that include http?

1 Like

Iā€™m not sure I understand the question but I suppose the answer is yes.

1 Like

Links that have http get counted and those that donā€™t are not counted?

That was my (hard to discern) guess.

1 Like

What would be an example of a link without http?

1 Like

Hmm. Yeah. I was thinking that some links were relative URLs, so didnā€™t have http,just started with /. But thatā€™s not it.

I got nothing.

1 Like

This is really puzzling. I now found an ordinary internal link (what you get via the :link: icon minus the username part) which has a click counter, but I also have multiple such links where clicks are not countedā€¦ :woozy_face:

1 Like

Can you make a post here with specific examples on meta?

There was meant to be a sample link in the OP but apparently I posted it without pasting the link. Fixed it now. Letā€™s see if it will get a link counter as predictedā€¦

In any case: could you clarify what the expected behaviour is? When does a link get a click counter and when does it not get one?

1 Like

Thereā€™s something suspicious going on? Or something Iā€™m missing.

I have two posts, linked with hyperlinked text.

When I go to the target link I see that itā€™s been visited from the first post several times (from the counter and link at the bottom of the post!), but there is no corresponding counter on the source pageā€¦

The link counters that donā€™t work have exactly the same format as the ones that do, they are all using the full URL including https and the domain and full path.

I dare say this might be some kind of bug?

1 Like

Iā€™m raising this as a potential bug.

Iā€™ve done a very little amount of investigation so far.

Iā€™ve confirmed so far that my suspicious links that are showing zero clicks exist in the table, and the count is zero. Thatā€™s so unlikely as to be almost impossible. So why arenā€™t the clicks accumulating? Other links within the same topic and post are accumulating fine ā€¦ (or perhaps its an intermittent issue so the counts are lower than they should be?)

Try it yourself in Data Explorer for suspicious links with no counter:

(the topic id is in the URL, naturally)

SELECT * from topic_links where topic_id = <your affected topic id>

Next, I clicked on the suspicious link whilst impersonating a user, logged out, logged back in as admin and then ran the query again. Still zero.

So this isolates it to the point of input perhaps? Perhaps in the code behind the click action ā€¦ or a data issue? But the data looks very like the data for the links that accumulate clicks. Except for the count ā€¦

I checked to see if the ID was unique (and presumably the id is a primary key in any case, but I checked anyway in case the wrong record is being updated) ā€¦ itā€™s unique.

Am I missing something here?

2 Likes

UPDATE: Iā€™ve found something here

I noticed the URL generated in the ajax call with path /click/track uses an out of date slug which was changed during the life of the target Topic - could that have affected it? I know most code should rely on the id only, but is this an isolated case where it requires the slug to remain the same as when the link was created in order to work?

BOOM, thatā€™s the problem!

Update the old slug in the source link to the new target slug and the counter appears.

The counters fail because the slug has changed - I think this should be fixed if possible as this should not be a dependency?

WORKAROUND: Update the source link to the new target slug and the counter starts working! @tophee @sam

Unfortunately this is a lot of manual work and you need to identify each mismatching link. A fix to remove this dependency to rely only on the id would be lovely :slight_smile:

Would be also good to check:

  • if the bug affects the ā€˜arrived fromā€™ counters in the post footers.
  • if adding a mid post location with a heading at the end of the url breaks the counter code e.g. #headingā€“myheading because Iā€™m not seeing any counters on those types of links ā€¦
2 Likes

Unfortunately, I cannot confirm this. Although I found one link where the target slug had indeed changed, but multiple others where correct but without a counter nonetheless. :woozy_face:

Ok but did fixing the slug add the counter in that instance? Worked for me. You may need to impersonate a user to accumulate a count (not sure if it registers admin clicks? Might not. Hence you need user account to check?)

Is it possible no user has clicked those links where the slug was up-to-date in the link? Donā€™t think using admin account is valid check.

i also think accumulation presently isnā€™t supported for targets involving mid post headings.

My edit is your answer @tophee, see first post

Thanks Jeff, lā€™ll confirm that one tomorrow too.

Any chance we can add counter support for those cases?

So you are saying that internal links will be counted if they donā€™t have a username appended but not if they do? (If so, is that intended behaviour and if it is why?)

This was one of the first things I checked before I wrote the post and could not confirm it. I have a long table-of-contents type post in which I intentionally omitted the username in order not to skew my stats, but none of the (internal) links had a counter. And this was the case also yesterday. Since people use that post a lot, itā€™s impossible that none of the links were clicked.

Looking at it today, however, I see some link counters appear for internal links. What has changed since yesterday? We upgraded to latest via a rebuild (because we had to remove the deprecated github linkback plugin).

So, if this ever was a bug (I was never sure from the start, because I wasnā€™t sure what the intended behaviour was), it may be fixed now.

But does anyone understand what was the cause of this? It looks like someone broke it and fixed it without even realizing it?

Or perhaps there are several things coinciding here? One is the thing with the appended username (which didnā€™t explain things for me), and another thing is some bug that was fixed in a recent commit.

Do any of your working links contain:

  • an out of date slug tested on latest, still not working/supported - slugs have to be identical to target.
  • a username (taking Jeffā€™s word for it, not tested).
  • a heading (mid-post) specific link? tested on latest, still not working/supported

Because I donā€™t think these are supported at the moment and will still fail.

Also Iā€™ve just edited a page (changed just one link) and most of the counters were reset to zero and this is reflected in the database ā€¦ (according to Data Explorer).

@zogstrip I saw you were looking at this, you might be interested:

  • Do we need to rebake posts?
  • Does rebaking fix out of date slugs?
  • Does rebaking reset counters?
  • Why would an edit of one link, reset all counters?

Some additional observations: I just changed the ownership of that table-of-content post I mentioned earlier and the effect was that all (both internal and external) links had their counters reset to 0; all but the first link in the post (which is an external link).

So there is definitely some huge incoherent behaviour here.

But apart from that it would be more coherent if all counters were reset (or only internal ones or only external ones), Iā€™m wondering whether a change of post ownership should/needs to reset any counter at all? After all, information is being destroyed here.

My proposal would be that neither rebaking nor change of ownership should reset counters.

Yes.

It should.

Yes, the fix is not retro-compatible.

In the case of the bug I fixed, that was because there was a discrepancy between the cooked link and the link we stored to count the clicks.

1 Like