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

manual onclick events cause JS error #8814

Closed
ctrl-alt-deleted opened this issue Sep 17, 2015 · 8 comments
Closed

manual onclick events cause JS error #8814

ctrl-alt-deleted opened this issue Sep 17, 2015 · 8 comments
Assignees
Labels
answered For when a question was asked and we referred to forum or answered it.
Milestone

Comments

@ctrl-alt-deleted
Copy link

Hello everyone,

I am trying to use onClick event tracking option, see below:

<a href="#" onclick="javascript:_paq.push(['trackEvent', 'Menu', 'Freedom']);">Freedom page</a>

this does not fire the event, instead JS error shown in the console.

TypeError: L[Y] is undefined ...=1){X=arguments[W];Y=X.shift();if(n(Y)){L[Y].apply(L,X)}else{Y.apply(L,X)}}}func...

further looking at the source it could be down to apply() function being the culprit

        var i, f, parameterArray;

        for (i = 0; i < arguments.length; i += 1) {
            parameterArray = arguments;
            f = parameterArray.shift();

            if (isString(f)) {
                asyncTracker[f].apply(asyncTracker, parameterArray);
            } else {
                f.apply(asyncTracker, parameterArray);
            }

    }

on LINE:598: asyncTracker[f].apply(asyncTracker, parameterArray);

@mattab
Copy link
Member

mattab commented Sep 20, 2015

Hi @ctrl-alt-deleted - can you try to add the Piwik javascript tracking code in the <HEAD>, does this fix the issue?

@ctrl-alt-deleted
Copy link
Author

@mattab tried , still get the same issue

@tsteur
Copy link
Member

tsteur commented Sep 21, 2015

Which version of Piwik are you using? How do you embed Piwik into your site? Are you using the default tracker code as shown by the tracking code generator?

@ctrl-alt-deleted
Copy link
Author

@tsteur

  • Version 2.14.3
  • the code embedded before the closing </body>
  • yea i am using the default tracker code, created by the generator

@tsteur
Copy link
Member

tsteur commented Sep 21, 2015

The problem is that asyncTracker[f] seems to be not defined which I don't really understand why this would be the case. Do you mind sending us a link to debug to hello (at) piwik.org and leave a comment here in case it goes to the spam folder? I'd try to reproduce on that page

@mattab
Copy link
Member

mattab commented Nov 26, 2015

@ctrl-alt-deleted could you help us? see previous comment

@ctrl-alt-deleted
Copy link
Author

@mattab i have sent a email , srry for late reply

@tsteur
Copy link
Member

tsteur commented Nov 26, 2015

Thx for sending us the email. I reproduce it. The seen error there is expected since it is not calling a valid method

javascript:_paq.push(['SEO1', 'test', 'Link1']); SEO1 is not a valid method.

It should be eg javascript:_paq.push(['trackEvent', 'test', 'Link1']);

@tsteur tsteur closed this as completed Nov 26, 2015
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Nov 26, 2015
@tsteur tsteur added this to the 2.15.1 milestone Nov 26, 2015
@tsteur tsteur self-assigned this Nov 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

3 participants