Trouble recreating Google Analytics (UA) events in GA4 - google-analytics

I have a bunch of mp3s and an audio player on my site. In GA3 (UA) I had an event that fired every time I hit the play button on a specific track. The event name was jPlayer, the track in question is the variable 'mediaName', which is the name of the mp3 file which is derived when I click play. In my code, mediaName is a string that gets sent out to GA. i.e. mediaName might be 'mycooltrack.mp3', or 'anothergoodtrack.mp3'
ga ('send', 'event', 'jPlayer', mediaName);
After reading the GA4 docs, I guessed that I needed to make a custom dimension, called "Track" which took the User Property/Parameter: mediaName.
So the new code in my function looked like:
gtag('event', 'jPlayer', {
'Track': mediaName
});
But after several days this hasn't been working either.
I guess I don't really understand what dimensions are and how to send an event with an 'on-the-fly' name variable to GA4, like I've been doing with UA for years.

You need to first create the event in GA4 interface. https://support.google.com/analytics/answer/10085872?hl=en&ref_topic=9756175#zippy=%2Cin-this-article%2Creserved-prefixes-and-event-names%2Cweb
It is under "Configure" on the left-hand side. Then go through the steps.
Your configuration will look something like this, if you really like the "jPlayer" event name, then just replace "audio_play" with "jPlayer"
The code you used is still relevant and can stay the same, I'd just write "track" in lowercase.

Related

Tracking sign_up event as a Goal in Google Analytics

I wanted to create a Sign up goal in Google Analytics. Adding an event for signup is simple enough:
gtag('event', 'sign_up', { method: 'Direct' });
This successfully created events
However when I try to configure the goal as such:
Nothing happens, the Goal conversion is not counted for the events shown above.
I am trying to follow instructions from here https://developers.google.com/analytics/devguides/collection/gtagjs/events
However I found very little documentation on tracking events as goals.
How do I configure a goal based on the standard engagement events in Google Analytics?
Try to set only Action equal to sign_up without value in Category.
I figured this out. The "Use the Event value as the Goal Value for the conversion" is the problem. Because my event is not sending a value, GA assumes it has zero value and zero value goals are not counted as a conversion.
I fixed this by choosing No for the option and entering 2.5 as the value. Now anyone sending the event counts as a conversion worth $2.5.

GCal API: responseStatus "forces" invitee accept?

Our app is creating calendar events. Trying different combinations of parameters, it looks like when responseStatus is set = true for a given invitee (and that invitee is a GCal user) the accept of the event is "forced" -- ie, if I was the invitee the event just shows up on my calendar as accepted without me having acknowledged the invite in any way.
Can this possibly how things are supposed to work? On the face of it, it looks like I can use API to fill up peoples' calendars with events, causing them to get alerts, lose their free-time, etc.
FYI, in my settings for "Automatically add invitations to my calendar:" I have "No, only show invitations to which I have responded". My calendar is also shared with everyone in my company.
You need to set responseStatus to needsAction.
Take a look at : https://developers.google.com/google-apps/calendar/v3/reference/events and search for responseStatus.

Trigger analytics event in the past with a specified date

I'm capturing the date of a product installation when user extends a trial, and pass it to a thank you page as a parameter. Then I capture it and want to retroactively trigger event in the past.
From docs the code looks like:
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
And nothing is said about ability to set any dates.
Is there a way to do it?
You can not push any events retroactively in Google Analytics.
All data is connected to the time that they were sent on.

How to Track Store Locator Search terms in Google Universal Analytics

I am in the process of setting up enhanced Ecommerce for GA and have had a few requests of additional of what else the client would like to see in their reports. Once of which is
"Where can i see a report if the locations that a use types in when they use the store locator"
There is already an internal search functionality thats been set up and is tracking the search terms people are typing when looking for products, but i'm not sure if i would need to set this up as a second search terms report or if it's something different?
The URL of the page is different to the internal search results and is www.domain.com/store-locator#wales|GB|0|0|0
Any insight into this would be really helpful.
Thanks,
Roxi
As to me knowledge, you are not able to use bookmarks (#something) in GA for internal site search setup. Only GET and POST parameters are allowed. In your situation I think the best solution is to use GA events to send the data about used location each time the user is using this functionality. You need to include addition ga() function call to track those events. Info about how to set it up you could find here: event tracking. After setting things up, you will see all the info about number and type of called events in Behavior -> Events reports section in GA.
Example code:
<button onlick="var hash_location=window.location.hash;ga('send','event','Locator',has_location)">Click me</button>
With such function new event will be send to GA with Event Category=Locator and Event Action=hash in the url. You have some complicated hash, so most probably you need to extract first some info from this using regular expression. Example to get first item from |-separated list in the hash:
var pattern = new RegExp('[^#|]+');
var hash_location = pattern.exec(window.location.hash)[0];

Google Analytics Tag Manager fails

Google recently released a new feature "Tag Manager"
https://developers.google.com/tag-manager/devguide#migration
https://developers.google.com/tag-manager/reference#varnames
Do you know any success stories and give successful site html-examples?
I was not able to make Events working.
Here is my site, but it fails. You can see which code is inside by Ctrl+U in FF.
http://landkey.org
When I click on test button which supposed to send this event: .....
input type="button" onclick="dataLayer.push({'bubbles_event' : 'ANCHOR_..... '}); alert('clicking'); " value="bubbles"
..... nothing is sent in "Net" pane.
In dashboard of "Tag Manager"/Container/Tags, I set up a tag, TrackType as "Event" setup event rule, and double checked this few times.
I'm wondering if you're running into an issue where there's a collision on the 'event' namespace. We've autocreated the 'event' rule / macro type to map directly to dataLayer.push({ 'event' : event_name }). This only works if you use 'event' as the key.
In your code example, it looks like you've chosen a different name for your event, called 'bubble_event'. The simplest suggestion I have for you is to just rename 'bubble_event' to 'event' in your data layer. That should hopefully work.
If you're attached to 'bubble_event', then you could create a macro of type Data Layer variable, where the data layer variable name is 'bubble_event'. Then you could create a rule where Bubble Event = whatever value you're looking for. However, it's best practice and recommended to just use the 'event' syntax wherever possible, since then you can consolidate all your events.
Give that a shot and let me know if you're still running into issues.
Cheers,
Laura

Resources