I have a question about Google Analytics Content Experiments.
My goal type is currently URL Destination.
And we push conversions manually to Analytics after phone call matching, normally it takes one day.
We use this code for pushing conversions.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'XX-XXXXXXXX-X']);
_gaq.push(['_setAllowAnchor', true]);
_gaq.push(['_trackPageview','/call/conv ']);
What I want to know is how do I push a conversion manually for a specific variation.
Thanks in advance for help.
In GA Content Experiments each variation has it's own url, so you'd simply use the fitting url as the second parameter to _trackPageview:
_gaq.push(['_trackPageview','/call/VARIATION']);
regards,
Eike
Related
I have implemented a feedback star rating on my website at the bottom of each page. They can select one to five stars and optionally send free-form comments. I have implemented gtag.js to send the star rating integer and comments to my GA4 dashboard. Code snippet is below; I have omitted the JavaScript which allows the user to set the variables, but this is working.
<script async src="https://www.googletagmanager.com/gtag/js?id=MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'MEASUREMENT_ID', {
'custom_map': {
'rating_dimension': 'rating_key',
'comments_dimension': 'comments_key'
},
'rating_key': 'this.value',
'comments_key': 'commentsValue',
});
</script>
gtag('event', 'rating_event', {'rating_key': this.value });
gtag('event', 'comments_event', {'comments_key': commentValue });
I went under Configure>Custom definitions and added the dimensions under the Event scope.
The data is being sent as an event, because this is something the user can optionally do on a page. I have verified that the data is sent to GA, I have the Google Chrome GA Debugger, and can see that it is arriving in the Realtime report under Events.
I would like to build a report which shows the page title/URL, the number of views, the length of time spent, along with its average star rating and any comments. I would like to have some adjustable controls so that I can configure this to be shown for a specified length of time. For example, if the page is modified, I can see the average rating before and after the change. Unfortunately, I am not able to build even the most rudimentary view of this data in the new GA web interface. I tried to modify various existing reports to include my custom dimensions, but they don't offer this option. I went under Explore and tried to add a Freeform report, but I can't get the data to show up there either, it only counts the number of times the event has occurred, which is not what I care about at all.
I have gone to a lot of effort to send the data to GA and had expected to be able to access the data and build a basic report.
Is it that you are unable to add custom dimensions and metrics to the free form exploration? Or when you want to add dimensions or metrics, they don't even show up in the custom section?
Normally you have to wait more or less (some say up to) 24 hours before being able to use custom definitions (metrics and dimensions) in any report.
this might not be your case, but I found your post looking for an answer to my problem, which is the custom metrics and dimensions are there, I am just unable to add them to the report, it looks like a bug, I click the + button, check the custom dimensions and nothing happens.
I need to split collecting data for two GA accounts, let`s name them UA-XXXXXXX-1 and UA-XXXXXXX-2. To implement this, I used example code from https://developers.google.com/analytics/devguides/collection/gajs/ (under "Pushing commands to multiple trackers also works" text) and here is my code:
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setCustomVar', 1, 'customVar1', 'cv1', 1]);
_gaq.push(['second._setAccount', 'UA-XXXXXXX-2']);
_gaq.push(['second._trackPageview']);
_gaq.push(['second._setCustomVar', 2, 'customVar2', 'cv2', 1]);
It is working, but I have both custom vars in both accounts. What I really need, is to track customVar1 only for UA-XXXXXXX-1 account, and customVar2 only for UA-XXXXXXX-2 account. Any ideas how to implement this?
First of all, _setCustomVar must come before _trackPageview.
Now to your problem:
This happens because User level custom vars are stored in the cookie. Since both your trackers share the same cookie the second tracker will be sent with the vars set on the first tracker.
You have 3 options.
1) Go With Universal Analytics
The right path here is to use Universal Analytics. Multi-tracking is not officially supported in Classic because it's buggy, as you probably noticed. And things are easy to break.
On Universal all custom dimensions are evaluated server side so this setup is supported. No data is stored on cookies for Custom Dimensions.
eg:
Provided you configured dimension1 on UA-XXXXXXX-1 and dimension2 on UA-XXXXXXX-2 through the Admin interface.
ga('create', 'UA-XXXXXXX-1', 'auto');
ga('send', 'pageview', {
'dimension1': 'cv1'
});
ga('create', 'UA-XXXXXXX-2', 'auto', {'name': 'newTracker'});
ga('newTracker.send', 'pageview', {
'dimension2': 'cv2'
});
More info:
Universal Analytics Advanced Configuration / Multiple Tracking Objects
Universal Analytics Custom Dimensions and Metrics
2) Keep Classic Analytics but, use session level customVars
If you definitively can't move to Universal Analytics and want to keep using Classic you can get around this issue by just using Session Level Custom Vars. To make it work you would only need to change the scope of the custom Var as seen below (from 1 to 2).
Unlike User scoped Custom Vars, Session Scoped CVs don't get stored on the cookie. So you will get around this issue. The downside is that the value will only be valid for that session, not future sessions from the same user.
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_setCustomVar', 1, 'customVar1', 'cv1', 2]);
_gaq.push(['_trackPageview']);
_gaq.push(['second._setAccount', 'UA-XXXXXXX-2']);
_gaq.push(['second._setCustomVar', 2, 'customVar2', 'cv2', 2]);
_gaq.push(['second._trackPageview']);
3) Keep Classic and User scoped CVs but use different cookies per tracker
You can configure GA to create 2 sets of cookies, one for each tracker one at the root domain and one at the subdomain.
If your site is: http://www.example.net setup your trackers like this:
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']);
_gaq.push(['_setDomainName', 'example.net']);
_gaq.push(['_setCustomVar', 1, 'customVar1', 'cv1', 1]);
_gaq.push(['_trackPageview']);
_gaq.push(['second._setAccount', 'UA-XXXXXXX-2']);
_gaq.push(['second._setDomainName', 'www.example.net']);
_gaq.push(['second._setCustomVar', 2, 'customVar2', 'cv2', 1]);
_gaq.push(['second._trackPageview']);
This MUST to be done in all pages of your site. Not only this one. This will make sure that each tracker uses it's isolated cookieset and customVars won't leak from one to another.
Notice that if your site can be accessed without www.. eg: http://example.net/ this will fail and there is no workaround. You can't create 2 sets of cookies with the same name in the same domain and path. You just can't.
Also if you use _gaq.push(['_setDomainName', 'none']); or _gaq.push(['_setAllowHash', false]);, the above trick won't work and cookies will conflict. Your data will be weird. Just don't do it. You've been warned.
I can't stress enough that this is provided without guarantees and if your data breaks it's on you. Multiple trackers are tricky and that's why it was never officially supported.
More info:
ga.js API Reference Domains and Directories
I am trying to set up my analytic account and wondering if anyone can help shed some light on what I may be doing wrong. I have 6 e-com sites with products and the shopping cart is on a 7th separate site. Each site has its own unique domain.
I have a property set for each domain and then one additional property that is set as a global account. The theory was to track for each separate property and then additionally in the global account. This might be overkill since I am not overly concerned with traffic on the individual sites. But what I am having trouble with is I am paying for adwords so the ad lands on a shopping1.com and checks out on shopping7.com its not registering as a conersion since there is a switch in the domain name.
Here is the code that I, any input on how to make all 7 sites work as one and adwords realizing there was a conversion would be greatly appreciated. Do I need to set the domanname element? Also, do I need to add code to everything that links back and forth to each of the separate sites?
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-site1']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
_gaq.push(['global._setAccount', 'UA-global']);
_gaq.push(['global._setAllowLinker', true]);
_gaq.push(['global._trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
The code is okay, but not sufficient. First yes, you should use _setDomainName (with the value set to the respective domain names shopping1.com, shopping2.com etc).
More importantly you need to attach the linker functions to links, forms and iframes (and redirects, although with redirects you need to do the linking yourself) - basically every place where people change from one of your domains to another (it's not necessary to attach linker function to links that do not go to your domains).
Google Analytics uses cookies to store data, which cannot be shared between domains. The purpose of the linker function is to attach session information to the url so it is transmitted to the other domain, where it is read by the Google script and stored into a new cookie. Take a look at the documentation to see how the _link and linkByPost-functions are used.
If you are doing redirects you need to be careful that the redirect keeps the Google parameters.
Linker functions result in very long and ugly urls. Cross domain tracking works much better with Universal Analytics where you only have to transmit a single parameter (the client id) between domains.
I wondered if anyone can point me in the right direction?
I have an iframe sitting on us.website.com, embedded inside a page on www.website.com - and I need to track each query string in google analytics for the us.website.com page.
i.e.
I have the query string data passing from the URL (address bar) to the iframe so when a form is submitted a tracking code identifies where the user came from.
www.website.com/offers/offer.html?src=source1 (form passes source1 as the entry source)
www.website.com/offers/offer.html?src=source2 (form passes source2 as the entry source)
Currently, all of the (us.website.com/offers/offer.asp) stats are shown under this one .asp page - but I need it to show stats for each query string.
i.e.
us.website.com/offers/offer.asp?src=source1 - individual stats
us.website.com/offers/offer.asp?src=source2 - individual stats
Is there a way to do this without building two separate .asp pages on the us.website.com domain??
Thanks in advance!
Simplest way is to create view in GA panel (filtered data). Of course you can tell GA to track different URL on every page, depending on parsed source but you are reinventing wheel, use filters.
var url = '/someofakename.asp?ada'
try {
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXX-Y']);
_gaq.push(['_trackPageview', url]);
} catch(err) {
//handle errors
}
I am combining Google Analytics' _trackEvent and _trackPageview into a single call, like the following:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20822178-2']);
_gaq.push(['_setCustomVar', 1, 'My Custom Page View Variable', 'My Value']);
_gaq.push(['_trackEvent', 'My Category', 'My Action']);
_gaq.push(['_trackPageview']);
[...GA snippet insertion...]
This generates two __utm.gif requests to Google. This would be okay except that the request with the _trackEvent information ALSO contains the CustomVar info, which leads me to believe that Google counts the pageview on BOTH requests. I don't want to double count my page requests... so is Google smart enough to throw away the pageview info sent with the _trackEvent call?
Thanks!
It won't double count page views but it is double counting your custom var. If you don't want that, reorder the pushes, make the trackpageview come first, then the custom var, then the event