GA event tracking mousewheel URL clicks - google-analytics

I have a webshop and would like to track when customers click-out on an URL (which refers to another website). I can only track these click-outs when people open the URL with a left click. If for instance, someone opens the link with a new page i.e. mouse wheel button click, then GA does not fire an event, thus no URL click is registered. As you can see the data for URL clicks is off since mouse-wheel interaction / right click actions are not monitored. Is there a way to monitor URL clicks which are opened in a new page?

The default mousedown event fires for all three mouse clicks in base JavaScript (and the on.click event in jQuery). The below code should fire for any click.
document.getElementById("foo").onmousedown = function(event) {
// Send GA Event
ga('send', 'event', {
'eventCategory': 'Category',
'eventAction': 'Action',
'eventLabel': 'Label'
});
};
Here is a fiddle with this tracking all three mouse clicks separately: https://jsfiddle.net/doctaj/fn0L2tbz/

Related

How to delay GTM tag firing?

The website has standard AddtoCart button but after clicking, user can add more units to their basket.
Problem is, AddtoCart event in dataLayer fires only once on the first clicking the button.
How can I delay firing the tag after this event so that I send final hit to GA when user is done adding units?
URL: https://shop.iglobus.cz/cz/rajata-cherry-na-stonku-strabena-250-g/8594192220046
This button:
becomes this:
Thank you.

addEventListener for gtag event tracking to Wordpress page

I want to add Analytics event tracking to a link on a Wordpress page.
The following code is added to the end of the body section. If I inspect the page with developer tools in Chrome, I can see that the EventListener is there for my a tag.
But the event doesn't get sent to Analytics...
document.addEventListener("FreeDownloadEventTracking", function(event) {
jQuery('div.free-download a').click(function() {
gtag('event', 'free plugin', {
'event_category' : 'downloads',
'event_label' : 'wordpress.org plugin link'
});
});
});
Can anybody tell me what's the problem here?
Thanks!
You are adding a jQuery click event inside a FreeDownloadEventTracking event, which I presume doesn't exist.
The page would need to trigger FreeDownloadEventTracking for your click event to be added to the download link.
I would suggest replacing FreeDownloadEventTracking with DOMContentLoaded so your click event is added to div.free-download a when the DOM is loaded. Then clicking the free download link will trigger gtag

Google Analytics Event [Form Submission] overfiring compared to actuals

I'm running into an issue for a form submission event firing too often (200x). The trigger for the event is created from the GTM standard Trigger Type of "Form Submission" where we're checking validation and have specified the conditions to be only on the Page URL where the form exists. We've tested it in GTM preview mode and seeing that the event fires.
Update 1/28-
The form is on a pop-up through our homepage (https://mybrightwheel.com) after the user clicks on "Request a Demo" (so the event fire should not happen on this initial button click). The event fire should occur after they get into the demo request form and complete a successful form submit. And below that is a shot of the trigger. Any help here is appreciated.
That trigger hasn't specified which button it's firing on. You have 2 buttons in that screenshot, it's recording both. You need to tell it to fire on one button or the other by specifying link text or link url (i.e. where the user ends up on clicking the link)

Google Tag Manager on exit page events performance

I have a page with search button, and an tag event that should be fired when the button is pressed.
My question is if the loading of the new page (that should be displayed when the 'search' button is pressed) will be delayed until after the code in the tag event is finished, or is it done asynchronously somehow
default loading of the new page will be delayed until after the code in the tag event is finished. Tags are usually fired as a listener to click event and they're executed before the default action. However, if your search button has some custom listener that redirects to a new page and overrides the default action then tag may not fire correctly.

How to track custom JavaScript event in Google Tag Manager?

I have a custom JS event that fires when accordion panel is opened. I would like to track the opening as Google Analytics event with panel id as the event label.
Using the old non-GTM approach I would do it like this:
$('#my-accordion').on('down.zf.accordion', function(e, panel) {
ga('send', 'event', 'accordion', 'open', panel.attr('id'));
});
But I would like to do this with Google Tag Manager and with as less changes in the code on page as possible.
So far I have created this in Google Tag Manager:
Trigger, type Custom Event that fires on 'down.zf.accordion'
Tag, type Universal Analytics with my tracking id, track type: Event (accordion, open, [probably a global JS variable that is set to panel.attr('id')?])
But the tag won't even fire when testing in the GTM preview. What am I doing wrong?
An alternate solution would be to use a Custom HTML listener tag that you could set to listen on your specified pages (eg. wherever you have an accordion on the page). The tag would look something like this, and require dataLayer events and values to be pushed:
$('#my-accordion').on('down.zf.accordion', function(e, panel) {
dataLayer.push({
'event': 'accordion open',
'category: 'accordion',
'action': 'open',
'label': panel.attr('id');
})
});
(Note that I haven't tested this out as I don't have access to Zurb foundation accordions - assuming that that's what you're using).
Your event tag could then be fired from the event "accordion open", and your event category, action, and label would be acquired from the dataLayer variables.

Resources