1

I am using Google analytics to track an event when a button is clicked. Please find below my piece of code responsible for that.

<script type="text/javascript">
            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', '@accountNumber']);
            _gaq.push(['_trackPageview']);

            (function () {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();
</script> 
<button id="button-submit" onclick="_gaq.push(['_trackEvent', 'CoreSiteCulture UK Submit', 'US Home', 'example.com']);">Save</button>

The the events are sent but they do not appear in Google Analytics events.

Does anyone knows what might be wrong?

EDIT: I am using the GA Debugger for debugging and it says Tracking beacon sent.

Leigh
  • 28,765
  • 10
  • 55
  • 103
user2307211
  • 117
  • 1
  • 1
  • 8
  • Any chance you are filtering the events? Can you see them in real-time reports? It might take some time (up to 24 hrs) for the first numbers to appear... – Petr Havlik Feb 12 '14 at 23:32
  • Is the event tracked in the debugger? Right above the `Tracking beacon sent!` the event should be recorded if it's processed. You should see something like this: `_gaq.push processing "_trackEvent" for args: "[` and below that: `Track Event` – jk. Feb 13 '14 at 01:36
  • yea it is processing fine. It just doesnot appear in google analytics. Seriously i cannot figure out what is the problem? – user2307211 Feb 13 '14 at 09:42

2 Answers2

0

Maybe the problem is not in production. Please check: http://oapp.com.ar/stack/index.html

The problem is that analytics can not be tested in local environment

  • 1
    welcome to stackoverflow! however, in the future, please refrain from link-only answers - please try to extract the meaningful parts of the link as it applies to this question and post here. – Corley Brigman Feb 11 '14 at 17:22
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – greg-449 Feb 11 '14 at 17:27
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Cyclonecode Feb 11 '14 at 17:42
0

For local testing, you need to add this

 ga('create', 'UA-XXXX-Y', {
 'cookieDomain': 'none'
 });

Here is the link for reference.