Hí!
I develop my website by Asp.net and I insert Google Analystic code inton Default.aspx file.
But I can't see its report?
Anyone experience with Google Analytic please help!
Thank in advance
It doesnt really matter if you put in in the <head> or somewhere within the <body>. Note that it takes a day for google to show your data. (Unless you are using the wrong tracker id)
You need your GA code on every page in your site. For your sake I hope you are using master pages so you can implement the code in one place and have it take effect for your entire project.
Here is an example:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PagePost.aspx.cs" Inherits="daniweb.web.PagePost" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Image ID="Image1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
</form>
<%--Begin GA--%>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-7065531-3");
pageTracker._trackPageview();
} catch (err) { }</script>
<%--End GA--%>
</body>
</html>
You need your GA code on every page in your site. For your sake I hope you are using master pages so you can implement the code in one place and have it take effect for your entire project.
Here is an example:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PagePost.aspx.cs" Inherits="daniweb.web.PagePost" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <asp:Image ID="Image1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> </form> <%--Begin GA--%> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-7065531-3"); pageTracker._trackPageview(); } catch (err) { }</script> <%--End GA--%> </body> </html>
Thank for your help, I will try
You're welcome
Please mark this thread as solved if you have found an answer to your question and good luck!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.