0

I'm attempting to use Gogole Analytics event tracking to track browser viewport size.

I'm using event tracking already in a bunch of other user-initiated places with jQuery and everthing works fine. This doesn't seem to be working though:

I have this at the bottom of my html page:

<script type="text/javascript">
<!--
    $(function() {
        _gaq.push(['_trackEvent', 'Viewport Width', $(window).width(), $(window).width() + 'x' + $(window).height(), 0, true]);
        _gaq.push(['_trackEvent', 'Viewport Height', $(window).height(), $(window).width() + 'x' + $(window).height(), 0, true]);       
    });
//-->
</script>

Not quite sure why nothing is being registered in Google Analytics. Half the day and nothing tracked. Also, Google analytics has Real-Time event reporting and I'm seeing other events come in but not these.

3
Contributors
7
Replies
27
Views
3 Years
Discussion Span
Last Post by Dani
0

I think you have the wrong link there :)

Parameter order shouldn't matter though since it's freeform, but interested to see the link u've got for me.

1

I was just able to et this to work:

<script type="text/javascript">
<!--
    $(function() {
        var viewport_width = $(window).width();
        var viewport_height = $(window).height();
        _gaq.push(['_trackEvent', 'Viewport Dimensions', 'Viewport Width', viewport_width + 'x' + viewport_height, viewport_width, true]);
        _gaq.push(['_trackEvent', 'Viewport Dimensions', 'Viewport Height', viewport_width + 'x' + viewport_height, viewport_height, true]);
    });
//-->
</script>
0

I think it perhaps didn't like numbers in the thrid parameter? I'm really not sure.

0

have you tried screen.width & screen.height
or document.width, document.height ?

or even top.document.width...

0

No because I stuck with jQuery and it's all working. Fetching the dimensions was never the issue.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.