asp.net web stats - google analytics - asp.net

i want to add tracking to my website. I saw google analytics which seems to track what i need.
So do i stick the google analytics snippet in each page, in a master page, just in my default page? what is the best practice here to get the best metrics.

The google analytics code snippet has to be on every page you want to track.
Easiest is to put the code into the master page(s) if you use them.
Otherwise put it on every page, or put it into a user control which you can include on the relevant pages or include it using a server-side include, e.g:
<!-- #include file="file_containing_google_analytics_code.js" -->

It depends on the structure of your site. If you have a small number of Master Pages it makes sense in there, or you could put some code to emit it in a base class that you inherit all your pages (or master pages) from, or if you have a standard footer control that you use on all pages you can put it in there.
I generally wrap it in a Placeholder in ASP.Net and have some code the switches it on/off from a web.config setting so it doesn't appear when the site is running in test/UAT/dev machines.

We use Google Analytics, and have incorporated this into our base page - although our first implementation was done with an HttpModule.
I like the base page approach, because it is a common area for some like-minded tasks. It additionally moves the viewstate to the bottom of the form, removes whitespace, etc.

You should take a look here : http://blog.sb2.fr/post/2008/12/21/Google-Analytics-WebControl-for-ASPNET.aspx

Related

Adding Custom Popups using google tag manager

When a user lands on a page, I want to show a custom HTML popup. I have Google Tag Manager integrated with the website.
Can this HTML Popup be shown using Google Tag Manager? (script and code to be inserted using Google Tag Manager)
Is it frowned upon / not advised to use google tag manager for
anything apart from tracking?
1.) Yes - GTM is pure Javascript, and inserts Javascript into the page code, so anything you can do you can do via GTM. There are some minor caveats (e.g. a size restriction on custom HTML tags), but doing a popup should work just fine.
2.) There are certain use cases that are discouraged - Google recommends against (or at least used to) making visible changes to the page markup via GTM. The problems with that are that GTM is loaded asynchronously, so you would not know at which point the changes show up and you might get "flickering" pages, and a possible performance impact when you force the page to re-render.
Nothing of this applies to popups, so you should be fine (although using popups these days might have its own problems, but these are not related to GTM).
Personally I would recommend against implementing popups via GTM if the popup is an integral part of your page; splitting up an application between page code and GTM code will sooner or later confuse a developer. But if this is just advertising or a call to action or something similar then (IMO) using GTM is not a problem at all.

Use Google Search Appliance Test center as my own aspx page

How would I use the view google has in the test center (where i test my frontend)?
When a user browse to site/search.aspx I want the to get the view testcenter shows, searchboxes and everything. I would also like to add my own javascript and css to the page.
Is this possible?
Now I have created a search box with updatepanel to show the results but this approach will force me to do a lot of parsing and setting variables for the dynamic navigation. I.e. a lot of logic Google already serves in test center.
By the way, I dont want to use the McA+ library supporting GSA 6.14.
I serialized the xml result from the GSA to C# objects and then fed them to my frontend where I could handle them.
Example of converting XML to HTML using XSL in C# ASP.NET can be found at: http://www.codeproject.com/Articles/469723/Rendering-XML-Data-as-HTML-using-XSL-Transformatio

Host .NET app inside HTML web page

The main page of our website is HTML. The powers that be want to put an asp.net calendar on this main page. Is there any better way to accomplish this than to use an iframe?
Start with this...
<div id="calendar">
View our calendar
</div>
Then use an AJAX request to replace the link with the actual calendar... works whether or not JavaScript is enabled / successfully fires!
Here is the jQuery way of getting the calendar...
$("#calendar").load("/ajax/calendar/");
I recommend that the first URL (the link to the calendar) links to a full page containing the calendar and the second URL (the link to ajax/calendar/) links to something that just returns the HTML for the calendar, to make it faster and less bulky...
All URLs are fictitious and any resemblance to your real URLs is purely coincidental.
If you control IIS - you could just map .HTML to the ASP.NET handler and add your asp:calender wherever you want.
If you're able to use JavaScript, then I would recommend one of the plethora of JavaScript calendars out there.
http://jqueryui.com/demos/datepicker/

Add-ons or libraries for adding user comment functionality to an existing ASP.NET page?

I have an ASP.NET site which I'd like to add page-level comments to without having to change everything over to a blog/CMS platform like BlogEngine.net, Wordpress, Umbraco, etc. Does anyone know of an add-on or library, either free or for-purchase, which can be added to certain ASPX pages to enable a stream of user comments at the end of the page?
The rest of the ASPX page needs to be able to have ASP.NET form controls, jquery and in some cases postback functionality I've written specific to the page which is why a simple blogging page is not enough as it means the blog engine owns the page aside from static content the site owner can enter.
Ideally there would be a way I could add a code snippet or user control to each ASPX page where I wanted comments and then they would show up and be managed independently on each page. I'd like to have the ability for users who post comments to be emailed when additional comments or replies are posted to their comment.
I am currently not locked into a particular authentication method so that is not necessarily a limiting factor.
This seems fun, I've not used it yet so I can't say if it works well or not.
http://developers.facebook.com/news.php?blog=1&story=198

Making a static ASP.NET site which has 100+ pages

I am converting an old html based website to ASP.NET, so that we can include more features like AJAX, Databases later on to the site. Currently my task is to create a new .aspx page for each older html page. To keep the layout persistent i have made a master page.
So currently i am building a content page from the master page, then renaming the content page and adding the text from the html page to the content placeholder area. However i was wondering if can cannot write a system, which can act as a Page Thrower.
Each hyperlink when clicked goes to a serverside code, where it requests the page it wants to load. Typically a webserver expects that the pagelink specified in the hyperlink does exist physically, but here what i am trying to do is that. Say the link is for the page "TravelDetails", the page need not exist physically, but the content of it is present in a file in (html format). so the Page Thrower gathers the data to display for that page, it has a master page already, it adds the html of it there and then throws the custom page. This way i don't have to keep 100+ aspx pages, i can do with a single page and maintain another data structure to store the content (static data) for each page. any guidance if my approach is right, and how to go about it?
Thanks
I think you should try some cms avaialable in market like dotnetnuke. Because every time you need to have to create a web page for a html page. In future if there will be any changes then it will take time. While in cms like dotnetnuke you just need to paste your html in existing system. You don't need to do coding again.
DotNetNuke is a free one. There are other Content Management System also available as well. Another advantage is that dotnetnuke is having skin features. So if you change skin at one place. You need not to do it for all the places.
Take a look at ASP.NET MVC. It uses ASP.NET Routing, which may help you.
Alternatively you can use ASP.NET Routing without MVC, too.
Matthias
Just a thought.
Create a page linked to the Master Page. In the content place holder add a Panel.
Let your Page thrower decide which page to display, retrieve the html data & add it to the panel at runtime.
Why don't you create the pages dynamically and then use asp.net caching in order to increase throughput.

Resources