Where Do I Place Google Analytics Code Inside .ASPX Page?
-
I just signed up with google analytics and I am trying to find where to add the tracking code on my page. I know how insert in basic html pages, I just have inherited a site that is a .aspx
-
Answer:
You can insert it anywhere and it would work, as long as it's not inside an ASP.NET control. A good place to put it would be inside your Master Page file, if you have one (that way you just add the code once for your whole site). Many front-end developers recommend putting your script at the bottom of the page, so that if it breaks, your page will still work. I think the Google Analytics code should be pretty solid though, so you could place it in your HTML head section.
user1350722 at Stack Overflow Visit the source
Other answers
The tracking code is profile-specific, which is why you can only access it via the Profile Settings page for a specific profile. Please read Where can I find my tracking code? for full instructions. Below is an example of what the code snippet will look like. You'll need to update the "xxx-x" in the sample below with your own Google Analytic account number found in your personalized Google Analytic Tracking Code.
user1335543
Take the https://developers.google.com/analytics/devguides/collection/gajs/ code (available in your Google Analystics pages) and place it just inside the <head></head> element of your code: <head> <meta charset="utf-8" /> <link rel="stylesheet" type="text/css" href="/css/screen.css" /> <link rel="shortcut icon" href="/images/favicon.ico"> <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> </head> If you follow the link above, you'll see that you can split the script block, so that some of the code won't impact on the rendering of the page. However, you'll run the risk of losing some hits, if the user interacts with the page before the tracking code is loaded. So only do this if you have a specific need to do so.
CJM
Related Q & A:
- Do I need to place the contributed modules inside "sites/all/modules" folder for drupal version upgradation from 6 to 7?Best solution by Drupal Answers
- How do I add Google Analytics to my Yahoo Group and Yahoo 360 Blog?Best solution by Yahoo! Answers
- Why do I get Google page instead of Yahoo page?Best solution by Yahoo! Answers
- Where do I enter a promotional code on national express?Best solution by vouchercloud.com
- How can I get Google off my Yahoo home page?Best solution by answers.yahoo.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.