I wanted to track the clicks on my contact form which is available on a different page. I know it is pretty easy. But along with that click tracking, I also wanted to track the page name (this will help me to understand from which page we have got more clicks).
-
As this is SO, please post some examples of code that you have attempted. This will help us in knowing what you've tried and where you may have gone wrong, so that we can help you better. – nyuen Mar 26 '15 at 15:54
3 Answers
It is easy. Category, Action, Label - these data You send to GA. Just mark event by unique Label equal to name of page, where this form is. That is all. But if a form is single and many pages - you just need to make custom report with Events and pages as second dimension.

- 89
- 5
To capture the event, you'd use the following standard event notation in an onclick or with .on('click tap touch') if using jQuery (also, consider triggering on submit instead of click):
ga('send', 'event', 'Contact Form', 'Click', document.title);
That being said, I'd recommend not capturing the Page Title in your event because you can see it using a secondary dimension on your Google Analytics report! This will save you extra room for more descriptive labels in the future.

- 3,971
- 4
- 20
- 28
I have used this code in the past. I included it in my core javascript that loaded on every page. It will track any click on any link, see if it's an external link (replace yourdomain.com with your actual domain) and then push it into Google Analtyics as an event.
$("a[href^='http']").click(function(e) {
var href = $(this).attr('href');
if (!href.match(/yourdomain\.com/i)) {
ga('send', 'event', 'Link', 'Click', href);
}
});

- 1,579
- 9
- 19