If a user doesn't list input anything in the top level domain list field then they will always encounter the error: "Uncaught TypeError: Cannot call method 'replace' of undefined" googleanalytics.js:11.

This occurs when a link is clicked. This occurs because the escapeDomains function is expecting a domain (text) when in fact it receives an undefined.

I think that if a user doesn't list anything in the textarea and they have "A single domain" selected, then that domain should automatically be used. This would stop users from having to come back and make changes when they switch from a development environment to production.

Comments

hass’s picture

Title: Top Level Domain List Requirement » JavaScript: Uncaught TypeError - Cannot call method 'replace' of undefined
hass’s picture

#1126462: Javascript error has eben marked as duplicate.

13rac1’s picture

sub.

Temporary Workaround: Select "Multiple top-level domains" and add dev and production domains to the "List of top-level domains".

hass’s picture

Status: Active » Postponed (maintainer needs more info)

Can you guys verify if you are really running the 1.2?

I'm trying to reproduce this myself with Google Chrome and Firefox 4 with Firebug for about 1 hour, but no luck. Can you give me a hint how I'm able to see the error message, please?

13rac1’s picture

Status: Postponed (maintainer needs more info) » Active

Hass,
I realize I've only been seeing the error in a specific browser...

  1. Start Internet Explorer. :-/ I was running IE8 with compatibility mode enabled most often.
  2. Click any link, and you'll see an error message icon appear momentarily. It is easier to catch the error by clicking an AJAX enabled link or probably even an anchor, so the page doesn't refresh.
codeamatic’s picture

I too, have only been seeing this error in the IE browsers.

altrugon’s picture

I can verify this is only happening on IE browsers on line #11

  RegExp.escapeDomains = function(text) {
11    return text.replace(/[-[\]{}()*+?.,\\^$#\s]/g, "\\$&");
  }

but the call to this function is coming from line #27

var isCrossDomain = new RegExp("^(https?|ftp|news|nntp|telnet|irc|ssh|sftp|webcal):\/\/.*(" + RegExp.escapeDomains(ga.trackCrossDomains) + ")", "i");
varunarora’s picture

This might be a stupid hackish temporary fix, but before line 27, try inserting:

if (ga.trackCrossDomains) var crossDomainVal = RegExp.escapeDomains(ga.trackCrossDomains); else var crossDomainVal = '';

I do not know how the module works - so I do not know if this damaging to the current functionality or not. eosrei's fix is not working as well as expected, because it messes around with the behavior of regular external links

moonray’s picture

Same error, until I updated to 1.2. That fixed it for me.

hass’s picture

Priority: Major » Critical
hass’s picture

Status: Active » Needs review
StatusFileSize
new1.01 KB

This patch should apply to D6 and D7. Can someone confirm if this works, please?

hass’s picture

hass’s picture

Removed one trailing space.

hass’s picture

Optimized condition.

hass’s picture

Version: 7.x-1.2 » 7.x-1.x-dev

Status: Needs review » Needs work
hass’s picture

Status: Needs work » Needs review
StatusFileSize
new4.47 KB

Fixed test.

Status: Needs review » Needs work
hass’s picture

Status: Needs work » Needs review
StatusFileSize
new4.48 KB

It's definitively to late.

hass’s picture

Status: Fixed » Closed (fixed)

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