I'm using Google Analytics for the first time. I've copied the supplied script tags into my page's header.
I can visit the page and I see one visitor in real time reports. In addition to recording the number of visitors to the page, I also want to report an event when a user clicks on a particular button on the page.
I have some jQuery to handle the click:
$("#new-preview").click(function(){
new_preview()
ga('send', 'event', 'preview', 'new', 'v1');
console.log('Click!')
})
I can see that the function runs because the expected text is logged to the console. However, no events are recorded in Google Analytics (Reports -> Real-Time -> Events). I following the instructions provided by Google here. I think I'm following them correctly.
Why isn't the event being recorded? What have I misunderstood?