I recently added the Google Classroom share button to my website. I'm looking to fire off a Google Analytics event every time this share button is clicked. I've tried using a javascript onClick to do it, but that didn't work. I think it might be because this creates an iframe when rendered by the browser.
$('#___sharetoclassroom_0').on('click', function(e) {
ga('send', 'event', 'gClassroom', 'gClassroom Click', 'Google Classroom Clicked');
}
I then saw the "data-onsharestart" attribute I can add to the Google Classroom tag and tried using that. That didn't work either...
<g:sharetoclassroom url="URL" data-onsharestart="gClassroomCount" size="20"></g:sharetoclassroom>
function gClassroomCount() {
ga('send', 'event', 'gClassroom', 'gClassroom Click', 'Google Classroom Clicked');
}
Any ideas on how I could add this event to the Google Classroom Share button?
You should try to use the debug version of the analytics.js library, that logs detailed messages to the Javascript console as it's running. These messages include successfully executed commands as well as warnings and error messages that can tell you when your tracking code is set up incorrectly. It also provides a breakdown of each hit sent to Google Analytics, so you can see exactly what data is being tracked.
Based from the blog, if you want a full control of the appearance and behavior of the share button (and don't need the callbacks), you can customize the Classroom icon as long as it still meets our branding guidelines and initiate the share via a URL of the form: https://classroom.google.com/share?url=https://foo.com/
You can also check this related SO question, hope it helps!
Related
I'm responsible for a department website for a university (https://www.unomaha.edu/college-of-business-administration/economics/). Because this is driven by a CMS, I can control a portion of the body section. However, the sausage code in the header or in the bottom portion of the body, I have no way to remove.
In the header of the page, the university has loaded Google Tag Manager. What I'd like to is record some in-page events using the standard Google Analytics approach. However, when these events are fired, (a) the event isn't recorded in Google Analytics and (b) if you have the Google Developer Console open there is a call to https://www.facebook.com/tr/.
I've tried this using both the dataLayer push method and a direct call to the "ga" function. Both result in no event recorded and a call to facebook. Directly looking at the dataLayer array in the console does show the event was pushed to the array.
gtag method (gtag defined earlier in the code):
gtag('event', 'econ_passion', {
'event_category': 'econ_passion',
'event_label': passion,
'event_action': 'open_passion'
});
ga method:
ga('send', {
hitType: 'event',
eventCategory: 'econ_passion',
eventAction: 'open_passion',
eventLabel: passion
});
What seems to be happening is that fbevents is dynamically loaded into the bottom portion of the body tag.
Has someone experienced this? Understanding that I can't actually remove the facebook code, is there a way you've found around this problem such that I can record G. analytics events?
You're using the wrong methods to push the event to GTM then GA. To track an event through GA implemented through GTM, you need to have access to the GTM container as well.
I'm trying to add a button to my website that will add an event to my google calendar, I found this url:
https://calendar.google.com/calendar/r/eventedit?text=Your+Event+Name&dates=20140127T224000Z/20140320T221500Z&details=For+details,+link+here:+http://www.example.com&location=Waldorf+Astoria,+301+Park+Ave+,+New+York,+NY+10022&sf=true&output=xml
which works and it's really handy to configure, but I'm wondering, because when I click on it, it takes me to google calendar and it will never come back to my site.
Is there a possibility to add a some parameter to once the event is added, make google calendar redirect to my website?
Thanks in advance.
No there is not a way to do this. Your best bet is to have this link open in a new tab/window so that the user still has your site open.
Another option is to use the Google Calendar API if you're adding a lot of events for a user and have them authenticate. This way you can just use an API to add events and keep them on the page. I would not suggest this solution if you're just adding an event here and there as it's quite invasive to give calendar access to an application.
My website has a tel: link in the header, and I want to see in Google Analytics when this link is clicked, and on what page. I've decided to do this using Event Tracking in Google Tag Manager. So I made a tag, with the following configuration.
And this is my Trigger configuration.
This is the HTML that this is referencing, (note that I also tried to add an onclick attribute, which was meant to push Event data directly to analytics. This didn't work.)
This is the variable configuration used in this tag.
This is proof it fires in the GTM debug pane.
And this is the summary coming in when you click on the item withing the pane.
In Analytics, this is what I see in the Real-time events tracking.
And this is what I see under the events overview.
So the tag is firing correctly, but the information is not going over to Analytics. I can find no resource on the internet that addresses this issue. Has anyone successfully pushed Google Tag Manager event tracking into Google Analytics? If so, what did you do to make it work, and what am I not doing/doing wrong that is preventing me from the result?
The end goal is I want to track the page where the click happened in Google Analytics' Events Overview, and also in the Goals section.
Thanks for that link, Uda! What was going wrong was my Google Optimize Tag. I paused all tags except my click-tracking and my Universal Analytics
I am using GA to analyze button click but it doesnt show them in the goal section. It just get displayed in the real time section.
My configuration:
Google Analytics configuration
Event sent via my onclick
ga('send', 'event', 'Buttonclick', 'Moveto', 'Register')
Everything looks good to me, too. You can confirm the event is actually firing with the "Google Analytics Debugger" Chrome extension. As long as that works properly, then you're golden.
Is there a way to catch the click event on the FourSquare follow button (https://foursquare.com/business/brands/offerings/followbutton) in order to add Google Analytics tracking with it?
Is there an API similar to the Twitter Tweet button and the Facebook Like button?
I couldn't find anything on the FourSquare site.
There doesn't appear to be comprehensive documentation of the Foursquare follow button, but I've been able to glean this much:
Unlike the Twitter and Facebook buttons, the Foursquare button is not in an iframe. That means you can capture clicks on it as you would clicks on any other element.
$("div[id^=fourSq_widget_id] a").click(function(){
_gaq.push(["_trackSocial", "Foursquare", "Click"]);
});
However, tracking this click doesn't mean anything; it doesn't tell you if the person followed through on the action of following, since that action takes place in a third party iframe.
There does appear to be an undocumented JavaScript API in the fourSq object for tracking the actual follow through on the action, but its not clear how to enable it.
It looks like it's something like:
fourSq.widget.Events.bind("follow", function(){
//do something
});
However, the only way I can seem to trigger it manually is with the accompanying trigger method. So, I'm not sure how to enable this undocumented JavaScript API so that it listens to actions taken in the modal window that pops up..
You could use Google Analytics Tracking feature, check this: http://code.google.com/intl/fi-FI/apis/analytics/docs/tracking/asyncUsageGuide.html