Google Analytics - E-Commerce portal - Track order flow - google-analytics

I'm working on an E-commerce portal and tracking my portal using Google Analytics, could see stats like,
Page Views
Unique Page Views
Location etc
Products could be added to Shopping Cart / Basket from any of the following pages,
Shopping Template
Quick Order form
Upload Order file
Normal Product Catalog page (Product listing page)
I would like to track from which Page(s) mentioned above, product gets added to the Shopping Cart and eventually Order gets placed, How can I achieve this?
Analytics script
<script type="text/javascript">
/* Google Analytics */
var googleAnalyticsTrackingId = 'UA-xxxxx-x';
var _gaq = _gaq || [];
_gaq.push(['_setAccount', googleAnalyticsTrackingId]);
var dimensionValue = '1234';
_gaq.push('set', 'dimension2', dimensionValue);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

Related

Using google analytics event tracking on 2 pages

Im working on setting up event tracking on a website, the user visits index.php, where he completes a quizz built with javascript, after answering each question i track the event with something like :
_gaq.push(['eventTracker._trackEvent', "myCategory", question_number.toString()]);
After the user completes the quizz he's redirected to another page : result.php where i track the landing event with :
_gaq.push(['eventTracker._trackEvent', 'myResult', myScore.toString()]);
The problem is that on analytics i can see the events with category = "myCategory" but not events with category "myResult".
Here is the code (this part is present in both index.php and result.php):
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-2']);
_gaq.push(['_trackPageview']); //an account for tracking page views
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script>
//the account we attach events to
_gaq.push(['eventTracker._setAccount', 'UA-XXXXXXX-3']);
//..... racking code as posted before

Grouping Blogger posts for blogs monitored via Google Analytics

I'm trying to exploit the content grouping feature provided by Google Analytics for a blog hosted by Google Blogger.
The blog has been correctly set to be monitored by using Google Analytics (GA). GA provides 3 ways of grouping but in my case only the grouping by tracking code option seems to be the correct one. As far as I can see inspecting a blog page, by putting into the template the GA include
<b:include data='blog' name='google-analytics'/>
I correctly get the following JavaScript ga.js snippet into the page
<script type='text/javascript'>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'XXXXXXXXXXX']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = (document.location.protocol == 'https:' ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
The problem is that I've no way to add the required call to set the group as required.
_gaq.push(['_setAccount', 'UA-40265412-2']);
_gaq.push(['_setPageGroup', 1, 'My Group Name']);
_gaq.push(['_trackPageview']);
Any idea in which way this can be implemented?
Thanks in advance

Google Analytics Ecommerce Tracking - Multiple Accounts

We are using Google Analytics on hundreds of client sites. Each site has its own account, and we also have an account for aggregate data. We're using the following code for tracking pageviews to both accounts.
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']); //obviously fake UA numbers
_gaq.push(['_trackPageview']);
_gaq.push(
['aggregate._setAccount', 'UA-87654321-1'],
['aggregate._trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
This is working well for tracking visits & behaviour, but I'm not sure how to implement the same type of double tracking for the ecommerce tracking code. We're using the usual _addTrans, _addItem and _trackTrans setup.
How can I adapt the ecommerce tracking to report to both accounts?
In your code, the aggregate. in the _gaq.push calls like aggregate._setAccount is used to create an additional named tracker.
Just copy the ecommerce _gaq.push code lines, and add aggregate. in front of the _addTrans, _addItem and _trackTrans calls.
For example,
_gaq.push(['_addTrans', ...parameters...]);
_gaq.push(['aggregate._addTrans', ...parameters...]);

Tracking Multiple Domains with Google Analytics in same code

I have portal which behaves like multiple portal.
The portal code base is same but for all sites but content is based on which url or domain you came across.
Currently i am able to track my domain
example.com
and also subdomains like
a.example.com, b.example.com
. But i want to also track
anotherexample.com
which also point to same domain. How can I do?
Any suggestions?
multiple url pointed to same code base. It does not matter. The only matter is the url above and the tracking code in site is matching or not. So you have to take google access code from database which just write in address bar.
Codes:
<!-- Google Analytics -->
<script type="text/javascript">
var accountNameFromDB = ...Some Operations...
var domainNameFromDB = ...Some Operations...
var _gaq = _gaq || [];
_gaq.push(['_setAccount', accountNameFromDB]);
_gaq.push(['_setDomainName', domainNameFromDB]);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Just take accountNameFromDB and domainNameFromDB variables dynmically.
Add this code head of master page(or main template) or add every page.

Using two separate accounts IDs for tracking

I have tracking code A on the main site www.example.com and tracking code B on www.example.com/blog which is a wordpress.com based blog (the site itself is plain PHP).
Not surprisingly, traffic from the blog is not shown on the main site and visa versa.
I would like to use tracking code A on the blog as well to create a "roll-up" profile while maintaining the profile I currently have with tracking code B.
I thought that the right way to do it is using the following code:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['t2._setAccount', 'UA-XXXXXX-2']);
_gaq.push(['t2._trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
but I read here:
http://www.google.com/support/forum/p/Google%20Analytics/thread?tid=640080c650f67bd1&hl=en
that it causes a multiplication in visitor numbers and such.
What is the correct way to do this?
Should I explicitly specify the domain and use the _setAllowLinker() method as described in the linked post above despite the fact that it's the same domain?
Any help will be much appreciated.
Thanks,
Alexander
P.S
I read Google Analytics - async tracking with two accounts but I still don't have a definite answer.
The easiest way to achieve the results you're looking for is to use a single account/profile ID site wide and use profile filters to create a 'Blog Traffic Only' profile.
Sitewide you would call:
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
Then, log in to Google Analytics, select your account (if you have more than one), add a new profile (for an existing domain) under the UA-XXXXXX-1 profile number, and call label it 'Blog Traffic'.
Once you create the profile, click to 'Edit' the profile you just created. Scroll to 'Filters Applied to Profile' and click 'Add Filter'. Google Analytics provides a pre-defined filter for traffic to a subdirectory (include only traffic to the subdirectories that are equal to '^/blog.*' or just '/blog').
Now, you'll have a profile that includes all traffic to your site and a second profile that includes traffic only to the blog subdirectory.
More information on using data filters:
http://www.google.com/support/analytics/bin/answer.py?answer=55496

Resources