1 Creating account in Google Analytics
1. Login the Google Analytics using Google Account.
2.
By default
Website option will be selected
3.
Under the section
setting up your web property give the details of the website
4.
In the website
name give the name of the website you want to track
5.
In the website
URL, enter the URL of the site.
6.
In liferay if you
want to track the activities of a site (community) give the URL of the site.
7.
Select the
category of the industry and select the reporting time zone.
8.
Give the account
name in the field.
Note: If you want to track the activities
of different sites, create different accounts for different sites. Then by
clicking on the particular account we can view all the activities of that site.
Fig2.1: Account
administration
9.
Click on the Get
Tracking Id button. It will redirect to a page where we can see the Tracking ID eg:UA-37377230-1
10. The tracking code will be displayed in the same
page. This will be used if site is
not developed using Liferay.
11. Adding the
Analytics tracking code to your website is the key to getting your reports
rolling. This is how Analytics and your website talk to one another and
Interpret information about visits to your
site.
2 Configuring the Google Analytics Tracking ID in Liferay
Go to the control panel and select a particular site and go to the site
setting of that particular site and from the right side section go to the
Advanced section and in that click on the Analytics link will be redirected to
a page where you can see the Google Analytics field place the tracking ID eg.
UA-37377230-1 in that field.
Fig3.1.1:
Deployment Diagram
All the pages of that site will have the Google analytics tracking
code.
3.Standard features of Google Analytics
The standard features of Google Analytics which comes with Google Analytics are
Number of visits for site
Unique visitors
Page views
Pages/Visit
Average Visit Duration
Bounce Rate
%New Visits
We can get percentage of
returning Visitor and Percentage of new visitors which helps us to calculate the performance of
the site.
In the home tab we will have the My Dashboard.
My dashboard shows the most important web analytics metrics of our
website in one page on one single dashboard
My dashboard we can have widgets and can display the statistics as
Metrics, pie chart, table and Timeline.
Fig4.1:
Dashboard
To know all the standard features provided by Google Analytics we can
explore the standard features under the overview, content and conversions
section in the right pane.
4
Introduction to Goals
Goal: a
page which a visitor reaches once they have completed an action
You
define goals based on the purpose of your website and the actions
You
want your visitors to take. Goals are often called conversions.
In one of the project the requirement is to track the comments, likes
and dislikes of a article by using Google Analytics.
To track this we have used event tracking in Google Analytics.
For that on the onclick of the button we have to write the event
tracking script which is similar to
onClick="_gaq.push(['_trackEvent', 'likes', 'like', 'article
name']);”
_gaq.push(['_trackEvent', 'Event Category', 'Event Action', 'Event
Label']);
In our example
Event Category---> likes
Event Action------> like
Event Label--------> article name
Article name we should get dynamically.
5 Analytics Report
• Page visits
Total monthly visits
Total monthly visits from Google search
Total monthly visits from Google ads
This
section will move through a handful of basic reports for page visits.
Remember to
set your date range to the last month of data prior to pulling your
Reports.
6 Creating a custom report
Goto the google analytics custom reporting tab.
Create a new Custom report by clicking on the new custom report tab as
shown below
Fig 6.1: Custom Report creation
In the title give the name of the custom report
select the flat table type
In the dimensions add Event label and Event Action
In the Metrics add Total events
In the Filter select the appropriate Event category and Event Action.
Click save
Then the report will be displayed select current date or the date range
from which you want the report and it will be displayed as below
Fig 6.2:
Custom report for Likes and Dislikes of a Article
Another requirement is we have to track how many times the article is
fully viewed
ie. How many times user have been redirected to the detailed page.
For that we have to write the event tracking script on the onload of
that detailed page so that whenever the user is redirected to the detailed page
the event count will increase.
Create a custom report similar to the likes report.
Fig 6.3: Custom Report for Page views
6.1 Code to be written in the Liferay Custom Portlet
Creating a
account in Google Analytics generates Tracking ID and Tracking code
refer Account creation section above for this.
The tracking code to be included in the javascript of the jsp of that custom portlet
<script
type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36598517-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);
})();
</script>
Code for getting the tracking Id of a particular site when user interacts
UnicodeProperties typeSettingsProperties =
themeDisplay.getScopeGroup().getTypeSettingsProperties();
String
googleAnalyticsId =
typeSettingsProperties.getProperty("googleAnalyticsId");
Code for tracking the event which is written on the onclick of the likes and dislikes button
onClick="_gaq.push(['_trackEvent',
'likes and dislikes', 'likes', 'Eventlabel']);
onClick="_gaq.push(['_trackEvent', 'likes and dislikes',
'dislikes', 'Eventlabel']);
where Event label is the
name of the article.
hello,where i would write the java script
ReplyDeletecode in liferay
i need to display page visit users names in google analytics using liferay6.2,but i dont know where i need to write the javascript code
ReplyDelete