Analytics
5.9K members online now
5.9K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

ga event tracking not working in Firefox

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

I have implemented google universal code as suggested from GA:

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-X', 'auto');
ga('send', 'pageview');

 

On some points, I want to call ga to track events:

 

ga('send', 'event', "My Category", "My Action", "My Label");

Everything works fine in Chrome and MS Edge. The event is tracked and I can see it in GA realtime event view.

But when I try it in Firefox, nothing happens. No event is shown in realtime view. There are no errors in firebuge console.

 

I tried it in privacy mode and even in secured mode (with all addons deactivated). But no event is shown in realtime view. 

 

In firebug network tab, there is only the http://www.google-analytics.com/analytics.js file loaded an no further requests is send to one of googles domains.

 

 

I now tried it on my notebook with an old version of Firefox (V29) and it worked as expected! But with latest version (44.0.2) it doesn't.

 

Any ideas?

Re: ga event tracking not working in Firefox

[ Edited ]
Visitor ✭ ✭ ✭
# 2
Visitor ✭ ✭ ✭

This may be one of those "is it plugged in" moments -- understand I'm not insinuating anything except pointing out something obvious, but easily overlooked...

Do you have do not track turned on in Settings --> Privacy?

 

Privacy Settings.png

 

Note that tracking protection is on by default in Privacy Mode, so we normally wouldn't expect tracking to work there regardless.

 

Re: ga event tracking not working in Firefox

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thank you for your reply.

First: Yes, its on, but I have tested it in Privacy, normal mode and even recovery mode. I also tried to uncheck the selectbox. In non of these cases the event was tracked in FF.

I tried it now on another computer as well. And there it worked with firefox version 29. After an update to latest (44.0.2) it stoped working for me :/.
So it may have something to do with firefox version.

By the way, my first try was with GTM: http://stackoverflow.com/questions/35411429/google-tag-manager-event-fired-but-not-tracked-in-ff-but...

Re: ga event tracking not working in Firefox

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭

Here's my latest finding. The get for the event fails to get a response code from the server, other calls to GA return server 200 responses (OK). Neither click or flyoutclick is getting out. Just to make sure it's not something with the newer FF releases I popped over to a page I literally just finished tagging a couple days ago with a custom event on form submit and... it fires just fine in the exact same FF that is failing on your site.

 

Let's recap here:

  • Your testing shows it fires OK in an older version of FF but fails in recent releases
  • My testing shows 2 event calls that fail (click and flyoutclick) - the request has no server response, BUT I am seeing the get happen within the browser
  • Copying the URL for the get request and pasting it in a separate tab works just fine.
  • My testing shows events are not definitively broken in recent FF releases as it works fine on one of my own pages

 

So.  There must be something "off" with your setup... but not so off that it fails to work in Chrome and IE (hah -- how often do you see something work fine in Chrome and IE but NOT FF? O_o).

 

I'm not going to dive too deep into your code, you know your site way better than I could possibly become by looking at your rendered HTML over the next half hour -- I don't see any markup to trigger your event on the images in your top nav.  I assume you are looking for the clicks on these images via CSS selector or some other way strictly within GTM?  Can you try setting up a throwaway/test event somewhere on the page itself (outside of the nav), preferably using the same technique to trigger the event in the nav images?  This will determine if the problem is a complication within your nav markup or if it's something in your event setup itself.

 

 

If the problem persists regardless of where/how the event is triggered, then would you mind recapping how you have this setup in GTM?  Do not show your UA-XXXX-## code or anything else that you don't want broadcast to the entire forum.  I'd like to know 1) how are you triggering your GA event and 2) the configuration of the GA event tag.

 

If I had to take a guess right now, I'd say you are probably using some JS injected via GTM that is handling some of the backend and there is something just slightly off which is only tripping up FF (maybe misplaced quotes or something off the wall).

 

Also, it looks like you started to rename the dataLayer but did not change it in the GTM snippet, so I suspect you're missing a bunch of data off the dataLayer too. Smiley Wink

Re: ga event tracking not working in Firefox

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭

Thank you for your close look and your effords to my problem!

 

Basically the corresponding js for the flyoutclick (GA-Event direct test without GTM):

 

$("body").on("click", ".linkarea", function(e){
	if(e.target.nodeName != "A"){
		$(this).find("a").get(0).click();
	}
});

$("body").on("click", "#navi_overlay a", function(e){
	ga('send', 'event', "Topnavi", "Flyoutclick", $(this).text());
});

As you can see, every click on any element inside a ".linkarea"-Div (for example the image, the teaser-text, etc.), which isn't itself an A-Tag triggers an click-event on the (first) A-Tag inside the div (in all cases, there is only one A-Tag inside this div). This logic is to get big click-areas, but only have a normal A-Tag with a single link text (for SEO reasons).

 

 

So if the user clicks on the "#navi_overlay a"-Tag (or the JS-Code triggers an click on such an a-tag), a normal GA event (Flyoutclick) is fired. But since the event is neither tracked, if I click on the image/teaser-text (JS click event), nor on the title (just a normal a-click event), I don't think it has to do with this code.

 

As I said, my first try was to do it with GTM with the same CSS-Selector (#navi_overlay a) (see screenshots in the stackoverflow question http://stackoverflow.com/questions/35411429/google-tag-manager-event-fired-but-not-tracked-in-ff-but...

 

Both (GTM "click" and normal GA event "flyoutclick") are working - as I said - in Chrome and IE.

 

My exact GA implementation is:

 

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-X', 'auto');
ga('send', 'pageview');

 I made now an extremly simple event test, by just adding the following line directly after "ga('send', 'pageview');", so no click-event or other magic needed, just fire an event on pageload:

ga('send', 'event', "Pageload-Event", "Test", "Test");

But its not working in FF (but in Chrome and IE it works)..

So it can't have to do with the specific click event handling.

 

The next thing I tried - I just created an empty html file only with the following js code):

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXX-X', 'auto');
ga('send', 'pageview');
ga('send', 'event', "Pageload-Event", "Test", "Test");
</script>
</body>
</html>

As you can see, its really minimalistic - no magic which could break my code.

Guess... Its not working in FF, but in Chrome and IE.

 

So where is my problem?

Re: ga event tracking not working in Firefox

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
I'm having the same issue with events in Firefox (although my code was put in the IT team, we don't use GTM).
Anyone have any idea what's causing this?

Re: ga event tracking not working in Firefox

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
I am having the same issue. Was there ever a fix found ?

Re: ga event tracking not working in Firefox

Visitor ✭ ✭ ✭
# 8
Visitor ✭ ✭ ✭
I think I got this solved by putting 'https:' in front of '//www.google-analytics.com/analytics.js'

So now it reads:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

Like Google suggests on:
https://developers.google.com/analytics/devguides/collection/analyticsjs/#the_javascript_tracking_sn...

And now it does get tracked when called from Firefox (v47.0)



ga event tracking not working in Firefox

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

I was going nuts on this for quite some time now and for me the reason was quite simple: uBlock was blocking Google Analytics. Since with the new firefox you have your addons on android/mobile version too now, it took me a while to get behind this. I am posting this here for others because Google Search led me here as one of the first search results.