Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#2866 closed Bug (fixed)

document.title is overridden by element with id=title or name=title

Reported by: rth Owned by:
Priority: normal Milestone: 1.7 Piwik 1.7
Component: Core Keywords:
Cc: Sensitive: no

Description

Using the default javascript tracking code with Piwik (1.5.1 and 1.6), sometimes page title is not recorded, the following text is shown instead

[object HTMLImageElement].

For instance, this happens when I am visiting the website. I can see the request send to Piwik and it contains
...
_viewts 1326571313
action_name [object HTMLImageElement]
ag 0
cookie 1
...

I also tried to put explicitly
piwikTracker.setDocumentTitle(document.title);
but without success.

This problem is only with one of the tracked websites and for visitors using Firefox or Opera browsers.

Please feel free to contact me if you require additional debug information.

Change History (12)

comment:1 Changed 2 years ago by vipsoft (robocoder)

  • Milestone set to 1.7 Piwik 1.7
  • Resolution set to answered
  • Status changed from new to closed

Make sure you call setDocumentTitle() before trackPageView().

On the pages where the title is showing as [object HTMLImageElement], check the page markup.

Please follow-up in the Piwik forum for further assistance. You can PM me the URL of one of the affected pages.

comment:2 Changed 2 years ago by vipsoft (robocoder)

Looks like this is a Firefox bug. https://bugzilla.mozilla.org/show_bug.cgi?id=446349

Check your page markup and fix the affected img tag. You're looking for something like these:

<img ... id="title" ...>

<img ... name="title" ...>

comment:3 Changed 2 years ago by longor

comment:4 Changed 2 years ago by rth

Indeed, this was the problem. Thanks for your fast reply.

comment:5 Changed 2 years ago by vipsoft (robocoder)

  • Resolution answered deleted
  • Status changed from closed to reopened

It looks like Mozilla isn't going to fix this. I'll add a workaround.

comment:6 Changed 2 years ago by vipsoft (robocoder)

  • Summary changed from page title not recorded to Workaround Firefox "feature" where id=title overrides document.title

comment:7 Changed 2 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [5671]) fixes #2866 - add titleFixup()

comment:8 Changed 2 years ago by vipsoft (robocoder)

  • Summary changed from Workaround Firefox "feature" where id=title overrides document.title to Firefox: document.title is overridden by element with id=title

comment:9 Changed 2 years ago by vipsoft (robocoder)

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Summary changed from Firefox: document.title is overridden by element with id=title to document.title is overridden by element with id=title or name=title

re-opening; it's also/still a problem in Safari and Chrome.

comment:10 Changed 2 years ago by vipsoft (robocoder)

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [5676]) fixes #2866 - in Safari/Chrome, getElementsByTagName returns an object with typeof "function"

comment:11 Changed 2 years ago by vipsoft (robocoder)

(In [5677]) refs #2866 - there is still a corner case if <title> tag is omitted entirely

comment:12 Changed 2 years ago by vipsoft (robocoder)

(In [5678]) refs #2866 - simplify

Note: See TracTickets for help on using tickets.