Friday, February 18, 2011

Tracking and Loging using Google Analytics

Hello Every one,
This is very important to check the popularity the site frequently, and for maintaining the same we can make use of the Tracking and Loging facility. What we do is simply get the Information that,

1 How many Members are coming to our site?
2. What is the geographical position of them?
3 What was the channel for them to visit our site?
4. And having the statistics in our hand for the performance measurement.

All this activity can be simply manage by using the Google Analytic. It is an enterprise class that let us know that what is the traffic in our site, How many new and old user are visiting our site, and many more, in a very easy way.


The Google Analytic handle all the headache of maintaining the traffic records and we can also view the report based in the Daily, Weekly and Monthly basic. What we have to do is , we just need to Registered into the site, to have an account where we can watch the activity, and a small piece of JavaScript code we need to put in our application that can track the page.


Now, Here the most important things is that if you just want to maintain the list of user that visited the site only, you can post the code in the Default or the Home page only, but if you wish to maintain the list of all the pages then place the code in all the pages.

If you are making use of the Master Pages, simply put them inside the master page so that they can appear on all the pages.

I will provide you the information that how can you set up the Google Analytic in your .NET application.


Step 1. Registration

You first have to Create an account with the Google Analytic for that make use of the URL.

SignUp

Provide the details there like Your UserId and password and other details and create an account.


Step 2. Confirmation Account

An email will be sent to you on the email address that you have provided while registration to activate the account. The email will contain a link and as you click that link your account will be activated.

Step 3. Sign-up to the account


SignUp to the account by using the User name and the password Provided by you at the time of registration.

Step 4. Provide the Website details

As you login to the site first time a page will be opened where you need to provide the information like your time zone and the website details.

Step 5 . Google Analytics Code

Once you fill that information you will come with a page where you will get a User id as UID.
This is your Unique Identification page that you must use inside the script of your page.

Step 6. Write the Script int the Code just below the End of Form Tag

You need to put the Script inside the page just before the end tag of the form tag, because this is the fixed location,. if there are any Master pages, put them just before the Form End tag.


<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_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>


In the Below line You have to Provide the ID generated or given by the Google at the time of registration.

_gaq.push(['UID']);


In Place of UID post your Unique Identification No.

Thanks all, You Tracking and login code is ready, you may wish to view the traffic by simply login to the Google Analytic site and viewing the reports.




I hope You have understood all the step as these are very easy to do and clear steps. If you want any more information you can log in to the official Google Analytic site.

Hope You have Like this Post, If there are any Queried please feel free to post a Comment.


Thanks

Anil Kumar Pandey

Tuesday, February 1, 2011

Sorting a DropDownList using Array list

Hello All,
We frequently make use of the Dropdownlost to display some list items, that may be country name, city name, Postcode , User Name and so many other things. At time we do not have the option to SORT all the list item. In this Code snippet, With the help of the ArrayList we can sort the items inside a DropDown.

The Array List is having a Inbuilt Sorting method which we can make use to sort any list. We simply Copy the Text and Value field of the Dropdown items inside 2 separate ArrayList and then We will add the Items from the Arry List to the DropDown.

Here is the Sample Code.


SortDropDown(ref ddlName); //Calling Method


private void SortDropDown(ref DropDownList objDDL)
{
// Decalre 2 ArryList to Hold the Text and Value of Items
ArrayList alText= new ArrayList();
ArrayList alValue = new ArrayList();


//Copy the Text field in the First Arry List
foreach (ListItem li in objDDL.Items)
{
alTextt.Add(li.Text);
}

alText.Sort(); //Sort the First Array List


//Copy the value field in the Second Array List based on First ArrayList value
foreach (object item in alText)
{
string val = objDDL.Items.FindByText(item.ToString()).Value;
alValue.Add(val);
}
objDDL.Items.Clear(); //Clear the Dropdown

//Finally Add the Sorted Value in DropDown
for(int intIndex = 0; intIndex < textList.Count; intIndex++)
{
ListItem itm = new ListItem(alText[intIndex].ToString(), alValue[intIndex].ToString());
objDDL.Items.Add(itm);
}
}



Hope you got this Clear idea about sorting the Arraylist. In cvase of Any issue Please send a Message.


Thanks
Anil Kumare Pandey

Kontera