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
Related
I have read some google analytic custom dimension explanations but still can't find a tutorial that explains the steps from beginning to end. I know many have discussed this but many tutorials are incomplete and jumping from the side of the settings in Google Analytics and from the side of laying the code in the project makes me confused.
What I have done,
First I add custom dimension from admin->custom definition->custom dimension
Then, I create a custom report from customization for showing my custom dimension
Then, I put the javascript code in my project
<script>
var test = 'test';
ga('create', 'UA-11xxxxxx', 'auto')
ga('set', 'dimension1', test);
ga('send', 'pageview');
</script>
But, If open the custom report it always returning no data(I have waiting more than a day but still no data)
Is there something wrong with what I've done or are there any steps that were missed?
Any helps will be appreciated. Thanks.
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'
});
I'm using GTM in my company's online shop, and I installed some other tag via GTM's custom HTML tag, like this:
<script>
//some JS code...
var customParam=[{"key":"value"}];
var jsElm=document.createElement("script");
jsElm.type="text/javascript";
jsElm.async=true;
jsElm.src="https://some_tags.com/tag.js?s=CV";
document.body.appendChild(jsElm);
if(today < some date)
{
SEND GA EVENT here.....
}
</script>
The traditional GA event script
ga('send', 'event', 'XXX', 'pageview', 'some description', 1);
isn't working anymore here.
How do I did this ?
And I heard someone said that I should put data into DataLayer and do some bla bla bla... but I was understanding that too few to try. Is that a right way ?
I am going to answer with another question. Why are you sending events through HTML tags instead of Google Analytics Tag that are build just for that purpose?
I ll work with the assumption that you are new with this tool but the idea is that GTM replaces all old GA code on site.
Just create a new Tag and select 'Universal Analytics' and after that you can choose which kind of information you want on Google Analytics.
Its pretty self explanatory as a tool so i strongly recommend you to forget about those old GA codes and work with what you got.
In addition to this have in mind that you can use custom javascript variables to scrap DOM values in case you need to.
Here is our guru Simo Ahava: https://www.simoahava.com/
If you need anything else just ask.
I currently have landing pages taking the following shape :
http://rootdomain/index.html?ref=[base64encoded-ref]&text=[base64encoded-text]
When I watch my stats in google analytics, I have urls looking like
http://rootdomain/index.html?ref=c3RhY2tvdmVyZmxvdw==&text=bWFyd2Fubg==
but I'd like to see
http://rootdomain/?index.html?ref=stackoverflow&text=marwann for example.
Any idea how to achieve this?
Oki so you can do this, but it can be tricky, so be careful.
Without GTM:
So on the page with Universal analytics, you can actually tell what must be the value that will be recorded. you can decode your path using JS and pass it like below:
ga('send', 'pageview', { 'page': '/YOUR-CUSTOM-PATH' });
Using GTM:
Changing the "dp" value can be accomplished in GTM by setting the desired value in the page field, under "Fields to set":
Let me know if you have doubts.
I installed Google Analytics (UA) and added tracking code to a html page.
I ran html page from the browser file:///C:/test.html and debugged using google debugger, it ran successfully and shows sent beacon - but Analytics does not show the numbers. I waited for a day but still does not work.
**It works fine if I place the file in c:\Inetpub\wwwwroot and run as http://localhost/test.html
-------------------Code in test.html page-------
<script>
(function(i,s,o,g,r,a,m)
{i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-******-*', 'auto',{'storage': 'none'});
ga('set', 'checkProtocolTask', null);
ga('send', 'pageview');
</script>
Can anyone tell me if google analytics works in my case.
What you want to do should definitely work, but you'll have to modify a few other things you're sending to prevent the hit from being dropped by Google Analytics.
Basically what's happening now is your hit is invalid. As you can see here using the Hit Builder tool.
I think you should be able to get around this by using the page field instead of the location field (which is auto-populated by analytics.js when you create the tracker), like so:
ga('set', 'location', null);
ga('set', 'page', '/test.html');
ga('send', 'pageview');
I've never tried this without also setting the location field, so it's possible Google Analytics will still complain that no hostname is present (Note: I tested this with Google Tag Assistant and it did complain, but it didn't say anything about the hit being invalid, so it will probably work fine.)
If using page instead of location doesn't work, you can always just modify location and give it a fake hostname, and that will definitely work.
ga(function(tracker) {
var oldLocation = tracker.get('location');
var newLocation = oldLocation.replace('file:///C:', 'http://fakehostname.com');
tracker.set('location', newLocation);
})
ga('send', 'pageview');
In either case, you won't need to unset the checkProtocolTask because you're now not using the file protocol.
Since it sounds like hostname doesn't matter in your case, giving it a fake value should have no impact on your reports.