Overlay doesn't work with this module.

CommentFileSizeAuthor
#7 piwik-overlay.png20.47 KBsoulfroys
#1 i1890136.patch1.33 KBattiks
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

attiks’s picture

Status: Active » Needs review
FileSize
1.33 KB
hass’s picture

Category: bug » support
Priority: Critical » Normal
Status: Needs review » Postponed (maintainer needs more info)

How have you been able to save a non-integer in the admin form? There is a validation that requires integers only. Otherwise you cannot use Piwik.

See http://drupalcode.org/project/piwik.git/blob/refs/heads/7.x-2.x:/piwik.a...

I'm not sure what all this stuff has to do with "Overlay" or what this exactly means.

attiks’s picture

The problem is that for Drupal it is a string, not an integer, and it was outputted to JavaScript as a string, inside piwik they check using !== siteId against a number, which always fails because it's compared against a string without this patch.

To test the new overlay from piwik, install the latest version

soulfroys’s picture

I backported this patch to version 6, but no success... humf!

hass’s picture

This means that http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_json_encode/7 may has a bug. It's just an integer and drupal_json_encode() makes it an string. Than we should better fix drupal_json_encode(). What PHP versions are you using? Just to find out of this may an issue of http://php.net/json_encode or the the drupal json helper.

JSON_NUMERIC_CHECK (integer)
Encodes numeric strings as numbers. Available since PHP 5.3.3.

Maybe better if the piwik guys will change !== to !=.

attiks’s picture

Status: Postponed (maintainer needs more info) » Needs review

I don't think so:

drush ev "print drupal_json_encode(variable_get('piwik_site_id', ''));" will print "1" because variable_get will return a string.

FYI: drush ev "print drupal_json_encode(123);" will print 123

soulfroys’s picture

FileSize
20.47 KB

Oh boy... after 100 attempts and settings, then realized I made ​​a classic mistake: always check the simple things first, ie, "the script is being inserted into the footer?". No!! What!! Then I inserted the "Standard JavaScript Tracking code" manually and ... voilà, it worked!

Piwik overlay

But ... my Piwik works normally without the code, all the statistics are there. So I wonder, what is wrong? This is not the right solution, since apparently the statistics are computed twice ... Any idea?

Piwik hook_footer:

/**
 * Implementation of hook_footer() to insert Javascript at the end of the page.
 */
function piwik_footer($main = 0) {
  global $user;

  $id = variable_get('piwik_site_id', '');

(..., blah, blah, blah, ...)

    $script .= 's.parentNode.insertBefore(g,s);';
    $script .= '})();';

    drupal_add_js($script, 'inline', 'footer');
  }
}
 
hass’s picture

This is a D7 case. Please do not highjack the case with unrelated issues.

haggins’s picture

According to the issue title, I seem to have the same problem as #7. When I try to open the page overlay (in Piwik) I get the following error:
The Page Overlay session couldn't be launched yet.
Maybe the page loaded on the right doesn't have the Piwik tracker code. In this case, try launching Overlay for a different page from the pages report.

Piwik FAQ lists some solutions: http://piwik.org/docs/page-overlay/#toc-page-overlay-troubleshooting

However, none of them fit my case. I'm using http and the (actual) tracking code is present in the footer.

Using D6 with piwik 2.4

soulfroys’s picture

Version: 7.x-2.x-dev » 6.x-2.3

@Hass, please, don't get me wrong, I'm just trying to help... It makes no sense to open another issue to discuss the same subject, I'm just telling to everyone: Hey! I'm investigating a bug in D6, because the problem occurs in both versions. By the way, I did not infringe any rule of Issue Queue Etiquette.

Anyway, I'm still your fan, I'm a fan of all the Drupal people that really contribute, as you do. I'm just trying to give my first steps...

soulfroys’s picture

Version: 6.x-2.3 » 7.x-2.x-dev

Oops (Now I hijack!)

haggins’s picture

Status: Needs review » Needs work

As Piwik overlay uses Drupals JQuery if present, I tested if JQuery 1.3.2 (latest D6 version) is the problem. But no. This can be excluded.

haggins’s picture

Ah, now I understand attiks point.

At D6 I just changed one line for testing:

$script .= '_paq.push(["setSiteId", ' . drupal_json_encode(variable_get('piwik_site_id', '')) . ']);';

to

$script .= '_paq.push(["setSiteId", ' . drupal_json_encode((int)variable_get('piwik_site_id', '')) . ']);';

And now it's working - thank you, attiks!

attiks’s picture

You're welcome :-)

hass’s picture

Status: Needs work » Needs review
haggins’s picture

A piwik bug report has been opened: Ticket

So there are good chances, that this will be fixed in one of the next piwik releases.

attiks’s picture

#16 Any chance you can commit this in the mean time?

hass’s picture

Wont't fix as piwik 1.11 has a fix. Leaving this case open just until piwik released 1.11.

kazudi’s picture

Version: 7.x-2.x-dev » 6.x-2.4
Assigned: attiks » Unassigned

Hey Guys,

i hope some one of you can help me, because the thread is a little bit confusing for me.

I installed the latest version of Drupal 6 and updated Piwik from 0.9 to 1.11.1. Now the tracking of my website works no longer. I understand integer-string-problem and in the bugtracker of piwik #3746 the problem is marked as closed.
Is the patch already part of the current piwik version (1.11.1) and when not, is there a solution to fix the problem.

Many thanks for your help

hass’s picture

Version: 6.x-2.4 » 7.x-2.x-dev
Status: Needs review » Postponed (maintainer needs more info)

Let's find out if the overlay works now with 1.11+

hass’s picture

Status: Postponed (maintainer needs more info) » Fixed

Issue is fixed in Piwik 1.11.1, overlay work well.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.