After upgrade to 1.8.4 outlink is wrong on 1 site

Hi,

Since upgrading from 1.8.3 to 1.8.4 I have a site that shows outlinks in the widget as “http:”

When I review the link they clicked on INSIDE piwik it shows that it starts with http://http://domainblahblah…

When I go to the site I am tracking the link is correct and takes the customer where he wants to go but Piwik is misreporting it in visitor report actions.

Some sites reported correctly and some didn’t have outbound clicks so I couldn’t compare. But definitely some are right and some are wrong.

I have attached screenshots of the various locations I referred to.

Any ideas to try?

Thanks,
Rex

Hi guys,

here are some questions that I’d be glad if you could answer, I will try to replicate the issue and provide a fix soon!

  • what version of PHP are you using?
  • Do you all have an issue with Outlinks only?
  • Do Downloads tracking & reporting work fine ?
  • Do you have linking problem in Actions > outlinks report & in Visitors > Visitor log ?

Thanks,
Matt

Hi Matt,
In my case I don’t have downloads so don’t know about that.

Outlinks are broken on ONE website and good on another. That’ll make it easy to find.

:D<

I can say that action>outlinks USED to display the link as:
r.popshops.com” and now display as “http:”

After exploding by clicking on the plus the links:
were " /r/WmVSd…blahblah" and now are “//r.popshops.com/r/M1R… blahblah”

So it used to show only the part after the popshops part and now shows the whole thing. Plus it used to have one forward slash … now two.
If I click on the link in the exploded Actions>outlinks it takes me to http.com and then throws the popshops link behind it.

Visitors>visitor logs is where I first noticed the problem. I get action link as “http://http://r.popshops.com/blahblah”. The two http in a row is a problem.

I just took a look in the mysql database using phpMyAdmin and it appears that the links are OK in the piwik_log_action table if I am looking in the right place. :wink: So at least we got that going for us.

Rex

What version of PHP are you using?

Also how do the link look like in log_action ? do they contain the http:// in the name column, or do they have only the domain+path ?

The server is a ServInt dedicated server running php 5.2.17

In phpMyAdmin looking at log_action I see an outlink of
http://r.popshops.com/r/UkpRaXNKbX...morestuff

So the link is fully qualified not relative.

Rex

Edit: I attached a screenshot.

screenshot not working? thanks!

I’ve got the same error but posted it before (Link).

The attached screenshot shows an external link in piwik_log_action with http:// in front of the URL, with type set to 2 and url_prefix set to 0.

I just had another look in piwik_log_action and saw that all old entries (entries before Piwik 1.8.4.) where set to type 2 (for external links, I suppose) and url_prefix is NULL. All old entries are showing up right in the list of external links except for the new ones. At the moment I’m unable to look into piwiks sourcecode but maybe I’ll have time for this later.

I did a small experiment on a test environment with a copy of my piwik database. I changed the value “http://example.com” to “example.com” in piwik_log_action and as a result Visitor Log was fine again. There was no double “http://” anymore.In Action > Outlinks the error with links sorted under “http:” was still there. Maybe there are two bugs and one could be in the method splitting protocol and path.

The proper behavior is that outlinks get stored with type 2 and url_prefix NULL in log_action. If you find something else in your database, it’s a bug. Please report it in this topic.

I suspect that the problem is the distiction between 0 and NULL. Maybe you PHP/MySQL configuration doesn’t handle that properly.

To debug, please edit core/Tracker/Action.php, relacing the method reconstructNormalizedUrl:

static public function reconstructNormalizedUrl($url, $prefixId)
{
	echo 'URL '.$url.': prefix ';
	var_dump($prefixId);
	echo '<br />';
	$map = array_flip(self::$urlPrefixMap);
	if ($prefixId !== null && isset($map[$prefixId]))
	{
		echo '=> '.$map[$prefixId].$url.'<br />';
		return $map[$prefixId].$url;
	}
	return $url;
}

Then, open the visitor log. You will get output like this:

URL http://example.org/foo/bars: prefix NULL
URL piwik.stage/test.html: prefix string(1) “0”
=> http://piwik.stage/test.html
URL http://example.org/foo/bar: prefix NULL
URL piwik.stage/test.html: prefix string(1) “0”
=> http://piwik.stage/test.html
URL http://r.popshops.com/r/M1R: prefix NULL

Please post this output (or send it via email to timo at piwik o r g) and tell me the URL that is not shown correctly. The URL has to be on the page of the visitor log you are viewing when copying the debug output.

When you do this, I can check whether the distinction between NULL and 0 works in your setup. If my guess is right, we can investigate further.

Thanks for you help!

Timo, I’ve just sent you an email with the debug output.

Everybody having this problem please take a look at the solution over here: Showing http://http://example.org for outlinks when using MYSQLI · Issue #3408 · matomo-org/matomo · GitHub

After performing the changes listed in the above post by Timo everything seems to be fixed. I held my breath making the mods but it all worked.

Thanks very much…

Rex

Kuddos Timo!!