Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setCustomUrl() support for relative URLs #2198

Closed
anonymous-matomo-user opened this issue Mar 17, 2011 · 6 comments
Closed

setCustomUrl() support for relative URLs #2198

anonymous-matomo-user opened this issue Mar 17, 2011 · 6 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

I'm using setCustomUrl() to fire a friendly URL from Drupal module into Piwik database for SiteSearch, but I still have issues and it's not working. I'd like to make sure that I'm doing everything correctly and the documentation of setCustomUrl() is not clear to me.

Can someone please explain me if the URL need to be absolute or relative and if relative is also possible if the leading slash may need to be removed?

Can you confirm if the following would be correct or what is incorrect, please?

_paq.push(["setCustomUrl", "http://www.example.com/drupal7/search?query=foo"]);
_paq.push(["setCustomUrl", "drupal7/search?query=foo"]);
_paq.push(["setCustomUrl", "/drupal7/search?query=foo"]);

I'd also need to know if setDocumentTitle():

_paq.push(["setDocumentTitle", "My document title"]);'

can be used together with setCustomUrl():

_paq.push(["setCustomUrl", "drupal7/search?query=foo"]);
_paq.push(["setDocumentTitle", "My search result title"]);'

or if need to expect issues if both are used together.

THX!

@robocoder
Copy link
Contributor

I've only used setCustomUrl with an absolute url, e.g., http://www.example.com/drupal7/search?query=foo. (I'm not sure we want to support relative URLs.)

use either or both setDocumentTitle() and setCustomUrl(); they are independent

@anonymous-matomo-user
Copy link
Author

I found a number of links before I started to use setCustomUrl() manually and this confuses me... urls seems all to be shown in Piwik UI, but SiteSearch is not working...

_paq.push(["setCustomUrl", "drupal7/search?query=foo"]);

My feeling is an absolute URL can be wrong in many situations. For example I'm using subdomains. From SiteSearch maintainer feedback, he is using the site URLs to find an URL and this can be wrong if I'm using a siteID on many sites. But I'm only guessing here if this could be a problem or not...

@robocoder
Copy link
Contributor

Mixing domains and absolute/relative paths will mash the results, e.g.,

setCustomUrl('http://example.com/A/B');
setCustomUrl('http://sub.example.com/A/C');
setCustomUrl('/A/D');

Under Actions | Pages, we see '/A' at the first level. The nested entries are:

/B - links to http://example.com/A/B
/C - links to http://sub.example.com/A/C
/D - links to http://a/D

In the last row, the 'A' is downcased and a link is created -- both transformations are arguably wrong.

@anonymous-matomo-user
Copy link
Author

Is it really a bug now or is it by design and it only need to be documented in the API documentation that the URL inside setCustomUrl() need to be absolute?

@robocoder
Copy link
Contributor

In 1.2.1, it needs to be absolute.

Going forward, I think we should support relative URIs. I'm going to open another ticket for the UI inconsistencies in Actions | Pages.

@robocoder
Copy link
Contributor

(In [4143]) fixes #2198 - thanks for raising this hass.

Limitations:

  • doesn't use document's base href
    • doesn't handle PATHINFO (used in PHP), e.g., if document URL is http://example.com/subdir/script.php/PATH/?query, setCustomUrl('test.php') will give us http://example.com/subdir/script.php/PATH/test.php
  • doesn't remove/merge '//', '/./', or '/../' in the relative path

@anonymous-matomo-user anonymous-matomo-user added this to the Piwik 1.3 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

2 participants