OnClick analytics not tracking (Wordpress Yoast Analytics) - wordpress

I have a Wordpress site using the Google Analytics plugin by Yoast. At the bottom of my website I have a few buttons/images going to sellers of our product. I gave all those links unique Onclicks but they are just not working.
I've tried GA and gaq_push, Onmousedown and onclick but not seems to work. Anyone knows why?

So the right code for Yoast is:
onclick="__gaTracker('send', 'event', { eventCategory: 'your category', eventAction: 'your action', eventLabel: 'your label'});"
Notice the _gaTracker that is different from the standard GA trackingcode.

Related

Use of Tealium to track multiple on-page tags for each Google Analytics Content Grouping

I'm in the middle of researching this and can't find a ton on the exact subject, so I was hoping one of you fine people might have the answer. Essentially, I'm trying to set up Content Groupings in Google Analytics for a network of WordPress installations where each blog post can have n number of tags and categories.
The Content Grouping would be something like Home Page, Posts, Pages.
Under the "Posts" Content Grouping, let's say I have a Movie post type that can track different genres (Romance and Comedy, or Science Fiction and Horror, or Action, Science Fiction and Horror, or even just Romance at times). I'd want to inject those into the page (easy enough to do), then loop through them and set them under the Posts content grouping for that particular page load.
However, the client is using Tealium for Google Analytics tracking, which adds a layer of abstraction to things. So the question is really a two-parter:
How would I fire off multiple tags for a given Content Grouping on a given page load so they're useful within Google Analytics?
How would I use Tealium to do that?
Tealium does offer up some documentation on Converting GUA Tracking to Tealium Tracking, like so:
Example GUA code snippet for event tracking
ga('send', {
hitType : 'event',
eventCategory : 'Videos',
eventAction : 'play',
eventLabel : 'Fall Campaign'
});
Converting to Tealium style by setting the ga_events variable with the GUA event fields:
utag.link({
ga_events: [{
eventCategory : 'Videos',
eventAction : 'play',
eventLabel : 'Fall Campaign'
}]
});
This is exactly the kind of Conversion Documentation I am looking for. However, it does not cover my use-case, which seems to require multiple calls to something like:
ga('set', 'Posts', 'Action');
ga('set', 'Posts', 'Science Fiction');
ga('set', 'Posts', 'Horror');
How would I do this (successfully) using Tealium?
Thanks in advance for any feedback or help anyone is willing to offer!
Edit
https://megalytic.com/blog/adding-google-analytics-content-group-tracking-to-a-wordpress-theme-using-google-tag-manager
This link talks about what I'm attempting to do, but using Google Tag Manager as opposed to Tealium. There is a lot of overlap there, so I'll try to dive in and find the equivalent process, but I'd still appreciate any help someone can provide!
It sounds like you'd be best off just writing your own custom javascript to manually fire your google analytics events. Could you use a custom container as described here? You can remove the script src if you don't need to load anything. You should then be able to have that container run on every page load.
Tealium works by mapping the variables in each tag.
First of all you need mapping the content grouping in your Google Analytics tag.
Then you can add the variable into the utag.link:
utag.link({
ga_events: [{
eventCategory : 'Videos',
eventAction : 'play',
eventLabel : 'Fall Campaign'
}],
Post : 'Action'
});

Establishing Page Titles for items categorized as (Not Set) within analytics only

Is there a way within analytics to have a specific page title display in place of (not set)?
I have several different items categorized as the page title (not set).. For example can I get randomlink/index to automatically assign to the page title "Landing Page" rather than (not set) within analytics?
Can this be done through content grouping or other methods?
The data already collected in Google Analytics can not be changed.
You can assign a value, in each page on the website that doesn't have a title, for future hits by providing a custom 'title' using the ga('set' script
eg:
ga('create', 'UA-XXXXX-Y', 'auto');
(...)
if (!document.title) {
ga('set', 'title', 'my custom title');
}
(...)
ga('send', 'pageview');
Make sure this code runs before a pageview is sent.
https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#title

Replace Google Analytics pageview URLs with Google Tag Manager

I have migrated from GA to GTM and I need know how to replace paths when sending pageviews URLs to GA. The reason is that our website has not category slugs, as example:
www.mysite.com/category-name/
While we want to track:
www.mysite.com/category/category-name/
IN GA we used to push a category slug replacing pageview URL:
ga('send', 'pageview', '');
This helped us to group together all categories. I think that we can achieve the same tracking in GTM using a Virtualpageview datalayer:
<script type="text/javascript">
dataLayer.push({
'event':'VirtualPageview',
'virtualPageURL':'<?php echo str_replace(get_bloginfo('url'),"/category/",get_permalink()); ?>', 'virtualPageTitle':'<?php echo the_title(); ?>'
});
'virtualPageTitle':'<?php echo the_title(); ?>'
</script>
So I created a GTM "Pageviews" tag with the following "Field to set":
page > {{virtualPageURL}}
title > {{virtualPageTitle}}
This tag is triggered with a custom event "VirtualPageview". I also created 2 dataLayer variables: virtualPageTitle and virtualPageURL. However GA continue tracking categories without slugs.
I will appreciate if somebody could tell me what's wrong in my settings, or how can I replace our categories URLs in order to send category slugs to GA.
Thank you.
The problem was that the page value must be relative, and I was sending an absolute URL. After changing it, I still couldn't see it correctly because of my Chrome cookies. I checked it with Firefox and finally I saw those slugs in GA.

Google Analytics event tracking

In the below code I want to added word say video name "XYZ" that should concatenate with Play.
I have code in which events are getting tracked if I don't concatenate video name.
ga('send', 'event', 'Play', 'pause', 'completed');
Can anybody suggest how can I concatenate the video name with Play in ga(..) code.
It's just Javscript, so you can put:
var videoName = 'Cookie Monster';
ga('send', 'event', 'Play-' + videoName, 'pause', 'completed');
If you use the Google Analytics Debugger (Chrome Extension), it'll confirm the code runs when it says: Running command: ga("send", "event", "Play-Cookie Monster", "pause", "completed")
Sameer, to get the name of the video, using the YouTube API, you can implement the answer in this question: Youtube API and tracking embedded video
Hope I've helped you.
Regards,
VĂ­tor Capretz

Social action tracking in Google Analytics

I want to track social actions in Google Analytics. I know I must use the following snippet, placed within the current analytics tag:
ga('send', {
'hitType': 'social',
'socialNetwork': 'facebook',
'socialAction': 'like',
'socialTarget': 'http://mycoolpage.com',
'page': '/my-new-page'
});
My question is this: Where do I place the snippet within the tag?
Correct placement might be after _gaq.push(['_trackPageview']); and before (function() but I am not certain.
Also, will I need to repeat this snippet per social network?
This code is only for the new GA API version (Universal Analytics).
You should use this documentation:
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial
The correct placement of this code is with trigger of each social network.
Here is an example for Facebook and Twitter:
http://analytics-api-samples.googlecode.com/svn/trunk/src/tracking/javascript/v5/social/facebook_js_async.html
And as the example, there is a code for each social network.

Resources