Trying to Implement Onclick event for the first time - event-tracking

I am trying to track the clicks on a link and the code I have used is this:
href="https://mattressfirmnewmexico.com/wp-content/uploads/2017/09/1.pdf" onClick="ga('send', 'event', 'Coupon Click', 'click', 'Coupon Savings $100 Off');
I have set the goal in GA as well, but when I am trying to check if my implemented code is correct or not I cannot see any data in the real-time event section. I can see myself as an active user but there is no data for the event. Attached is the picture if you all can see.
I don't understand where am I going wrong that I am unable to see the real-time data as well.
I am implementing this for the first time, so any kind of help will be appreciated.
GA Snapshot:

You must add the double quote:
href="https://mattressfirmnewmexico.com/wp-content/uploads/2017/09/1.pdf" onClick="ga('send', 'event', 'Coupon Click', 'click', 'Coupon Savings $100 Off');"
as Code Gorilla said

Related

Google Tag Manager tracking drop down menu/list (Web app built in R-Shiny)

I have a R Shiny app that I have connected to Google Analytics using Google Tag Manager (R Shiny app means AJAX website). I am currently tracking the standard stuff like PageViews, and have set up a tag to track which Tab a user clicks on (Using Click Element).
In most tabs, I have a drop-down menu/list (can be seen in the picture). When clicking on this list to select/change the input, the click element does not fire. So clicking does not work here.
In the same picture, I have included the source html code. I highlighted what I think is important. The default input is "Age Group (Discrete)." The "option value=" and "selected" changes the input (changed to "Pyramid (Discrete)"). And it also changes in the div class="item" data-value=..." line.
I do not know how to capture when a user changes the input using Google Tag Manager. I am however able to successfully track this if I put this GA code in my JavaScript file.
$(document).on('change', 'select', function(e) {
ga('send', 'event', 'widget', 'select data', $(e.currentTarget).val());
});
But the above only works if I also have this included:
ga('create', 'UA-######', 'auto');
ga('send', 'pageview');
Which means it is double-counting pageviews (tracking page-views on GTM and the GA code above).
I prefer to track what I want using just GTM. Any help would be appreciated. Let me know if the image is hard to see (May need to zoom in). Thanks
one possible solutions is using GTM custom events:
1) adjust your code to trigger custom event instead of sending GA event:
$(document).on('change', 'select', function(e) {
dataLayer.push({
'event': 'widget data selected',
'selected_value': $(e.currentTarget).val()
});
});
This will trigger specific widget data selected select that can be catched with Custom Event Trigger. Then just use that trigger for your regular Analytics Event GTM tag.
Additionally, you might set up user-defined Data Layer variable to read the selected option value from dataLayer and use it in your tag.

Google Analytics Events Tracking not working

I've being tried to install google events tracking on several sites but with no luck. I really want to know why its not working.
I installed events tracking on this site http://bedsndrinks.com/, the second "Book Now" button, here is the code I added to the button onClick=”ga(‘send’, ‘event’, ‘book form’, ‘click’, ‘book now’);“
I tried to use Google Analytics Debugger, but I don't see any "event" hitType. one thing I noticed is that the tracking code looks okay in source code but different when I inspect it in Chrome.
You need to check how your onclick is being rendered. When I loaded the page I saw the following:
<input id="sendBook" type="submit" value="Book Now"
onclick="”ga(‘send’," ‘event’,="" ‘book="" form’,="" ‘click’,="" now’);“="">
As you stated in your question, the format should be as below:
onclick="ga('send', 'event', 'book form', 'click', 'book now');

Google Analytics - show pathname in label

We're tracking events on our website and we've managed to implement this:
ga('send', 'event', 'Download', 'completed', 'pathName/filename');
For when a user clicks on a pdf download link. The "pathName/filename" is eg. "whitepapers/mywhitepaper.pdf"
What should I write in the Goal details:
label equals to ...?
label starts with ...?
label regular expression ...?
In a way, the question is similar to this one, with the important difference that I've implemented that part with someone's help but I don't know what do to next in the Analytics to reflect that.
Thanks!
Serge

google analytics reading the report - click event detail?

I'm using google analytics and am using this code as an example to capture a click event.
ga('send', {
'hitType': 'event', // Required.
'eventCategory': 'button', // Required.
'eventAction': 'click', // Required.
'eventLabel': 'nav buttons',
'eventValue': 4
});
where do I find this data in the reporting?
what I am able to find is event catgory buton but I cant find where this button was clicked with eventValue 4.
Can you please help.
I'm pretty sure that you misunderstand what "event value" means - this is to monetize non-ecommerce events. Which means event value is a metric, which in turn means that the values for multiple events will be added up.
So, the only case where you could possibly see the value "4" is when you isolate one single event. Else you will see a total (or average) for all events with the selected category/action/label (depending on the report).

Custom Dimensions in Universal Analytics firing multiple times

I'm not sure if this is an issue or not, but any clarification would be very helpful.
Every time there is a separate event on a page the custom dimensions will fire again (they are first fired during the pageview tag).
On the order confirmation page each custom dimension I have set up for that page is sent at least 4 times. Once on the pageview tag, once for the Event I created, once on the transaction tag and once on the Item tag.
I guess if you are looking at your custom dimensions at a visit level it won't matter but if you are looking at pageviews or hits of the custom dimension this might be an issue.
Does anyone know if this is actually an issue?
Thanks,
Frank
code looks like this:
ga('create', 'UA-11111111-1', 'mysite.com');
ga('set', {
'dimension1': Value1,
'dimension2': Value2
});
ga('send', 'pageview');
ga('send', 'event', page type,'Stage x',value);
ga('require', 'ecommerce', 'ecommerce.js');
ga('ecommerce:addTransaction', {
'id': order id,
'affiliation': '',
'revenue': revenue total,
'shipping': shipping cost,
'tax': transaction tax
});
Do you set the value with ga('set'...) ? If so you could try alternative syntax:
ga('send', 'pageview', {
'dimension1': 'My Custom Dimension'
});
However if the dimensions are session- or user- based it does not IMO make a difference. If they are hit based it depends on what you want to do (e.g if you want to filter/segment events based on hit level custom dimensions you need to send them along with the event, so it is not just a cosmetical difference).
EDIT
Looking at your code - yes, this is expected behaviour, you are setting the dimension for all subsequent calls. It is not an issue as far as data limits are concerned (custom dimensions do not cause additional interactions). So, not a problem, you will have to decide if you think you need the data (i.e. can your custom dimensions reasonably applied to an event), but even if you don't there are afaik no technical concerns with sending it anyway.

Resources