Forums » Help & Troubleshooting



Uncaught ReferenceError: clicky is not defined

I am trying to track an event as part of a jquery handler.
My js code, defined in $(function() in the form of an $.fn.extend, runs OK, and it ends with the
clicky.log(this.href, sLoggable);
call, as suggested in the description: https://clicky.com/help/faq/features/events/howto
But the console shows "Uncaught ReferenceError: clicky is not defined" (Firefox)
I have tried loading the clicky tracker before my jqeury code and also tried calling $.fn.clicky.log(...) but the result is the same.
Any ideas?
Logging works OK otherwise.

Posted Sat Feb 3 2024 8:55a by broadst***


Are you running an ad-blocker? Sounds like your browser blocking the tracking code from loading.

Posted Sat Feb 3 2024 11:17a by Your Friendly Clicky Admin


Yes, whitelist '*.clicky.com' on your whatever-blocker. It does help.

But consider:

"Clicky is not defined" could mean that your JS failed elsewhere.

I often get "jQuery is not defined" because my Angular (or whatever) had a typo.

So cool to hear of others using clicky.log() which I use prolifically.

Posted Sat Feb 3 2024 12:54p by gladiu***


"Logging works OK otherwise." -> you mean console.log() ?

The browser debugger is invaluable here, you know, "Inspect" --> "Debugger" and set some breakpoints. I'm lazy and never do this, but when I do, it gets fixed :) :)

Posted Sat Feb 3 2024 12:59p by gladiu***


!

Posted Sun Feb 4 2024 6:40p by devteh***


Thank you for your input!
When I said 'Logging works OK otherwise' I meant to say that the visit was reflected in clicky apart from the logging of the specific clickly.log() data.
However, thanks to your suggestion of debugging, I now realised that in my case instead of this.href a window.location.pathname input should have been provided, because I wasn't trying to analyse an click.
I also could have changed the order of the loading of the scripts so that clicky is loaded first, followed by my own script. I am not sure if this contributed considering that there might have been this other bug related to the href functin parameter.

Posted Mon Feb 5 2024 12:48a by broadst***


All in all it works fine now, at least on my compouter. I'll see in a while if visitors are also logged properly.

Posted Mon Feb 5 2024 12:49a by broadst***


"I also could have changed the order of the loading of the scripts so that clicky is loaded first, followed by my own script. I am not sure if this contributed considering that there might have been this other bug related to the href functin parameter."
While I am not a robot, this sentence makes absolutely no sense.
What I meant was that I also changed the order of script loading, moving clicky to be loaded first, followed by my own script. And I am not sure if this had anything to do with resolving my problems because the href parameter also had to be changed.

Posted Mon Feb 5 2024 12:52a by broadst***


Great! Yeah I thought you meant that tracking was working for other people, but when you were testing yourself, it wasn't. That's why I assumed adblocker!

Indeed, "this.href" will only work for event listeners attached directly to links, but glad you got it all figured out and working now!

Posted Mon Feb 5 2024 2:58p by Your Friendly Clicky Admin


Thank you for the help.

Posted Mon Feb 5 2024 7:58p by broadst***


You must be logged in to your account to post!