I have this code in my master page in the head section:
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta name="google-site-verification" content="830gFtORfJaVYXiLQ6EVfCNoiMW3zyn2DVS7L1zbr20" />
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-23254350-2']);
_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>
The problem is that google analytics is not seeing the tracking script. Any ideas?
I usually find that the tracking status updates pretty quickly after a page has been viewed and the tracking beacon has been sent.
You should go to the homepage of the site where this is installed and check that the JavaScript code is present in the page source in case the asp code has removed it somehow.
If it's there then you should use something like the Firefox Live HTTP Headers addon check that a request for an image called __utm.gif is being made to Google Analytics.
If that's all OK but the status is still not updated you could try checking that you've entered the correct account number into the tracking code.
Related
I have a content page in ASP.Net web app.
In that I am trying to use Jquery UI Autocomplete. But it does not work. What is wrong in this page? Here is my code:
<asp:Content ID="Content3" ContentPlaceHolderID="contentMainBody" runat="server" >
<link href="Atlas_Css/menu.css" rel="stylesheet" type="text/css" />
<link href="Atlas_Css/jquery.simplyscroll.css" rel="stylesheet" type="text/css" media="all" />
<link href="Atlas_Css/Jquery%20UI.css" rel="stylesheet" type="text/css" />
<script src="JS_AtlasFly/jquery.js" type="text/javascript"></script>
<script src="Scripts/Validations.js" type="text/javascript"></script>
<script src="JS_AtlasFly/jquery.simplyscroll.js" type="text/javascript"></script>
<script src="JS_AtlasFly/jquery.simplyscroll.min.js" type="text/javascript"></script>
<script src="JS_AtlasFly/js-image-slider.js" type="text/javascript"></script>
<script src="JS_AtlasFly/accordian.pack.js" type="text/javascript"></script>
<script src="JS_AtlasFly/jquery-1.9.1.js" type="text/javascript"></script>
<script src="JS_AtlasFly/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload = function ()
{
var availableTags = [ <%= PassFname %> ];
$("#txtFname" ).autocomplete({
source: availableTags
});
}
</script>
<div id="testDiv" runat="server">
<asp:Label ID="lblName" runat="server" Text="F Name"></asp:Label> <asp:TextBox ID="txtFname" runat="server"></asp:TextBox>
</div>
NOTE: the server side variable, PassFname, I am populating in code behind .
In a normal asp.Net page , without using master page (within the same project), Autocomplete works fine.
What is wrong in this page? is it because of master page?
What is the solution for this?
Since the same code behind code works in another page, I am not including it here. I have checked it here also, the string variable is populated on page load. Only autocomplete is not binding.
Any help will be appreciated.
I found the solution to this. I used the clientId of the TextBox directly in
Javascript.
like this:
$("#ctl00_contentMainBody_txtFname").autocomplete({
source: availableTags
});
that solved the binding of autocomplete with the textbox's id.
BTW, using <%=txtFname.ClientID%> doesnot solve the issue. Instead the page stops rendering.
So I used the client Id from page source, and it works.
Thanks to all
According to google plus documentation and other questions, the following code should add a default description when sharing:
META:
<meta property="og:title" content="TITLE HERE" />
<meta property="og:image" content="https://si0.twimg.com/profile_images/604644048/sign051.gif" />
<meta property="og:description" content="DESC HERE" />
<meta name="description" content="DESC HERE" />
HTML
<div class="g-plusone" data-annotation="inline" data-width="300"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
However, while the image and the title work, there is no description when sharing.
The code above is also on jsfiddle.
Here is the code in the head of my master page ...
<link rel="stylesheet" type="text/css" href="App_Themes/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>
but when i see it in the browser view source ... it is showing it like this
<link rel="stylesheet" type="text/css" href="App_Themes/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>
<link href="App_Themes/Site/style.css" type="text/css" rel="stylesheet" />
You notice there is a theme rendering at the end App_Themes/Site/style.css before the tag ... please tell me how can i fix it ... I need google analytics code before the tag ... but this theme rendering at the end forbids me to achieve my goal ...
I am going to guess you're using ASP.Net Themes?
ASP.Net renders your Theme and adds the style to the page.
Your best place to put the Google code is at the bottom of the page just before the </body> tag.
Google in fact recommends that it go just before the closing body tag, as documented here after the standard setup snippet
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingOverview
I add FaceBook Likebutton, Google +1 button and Twitter button to MasterPage.master and let these
button to display on all my webpages.
My IPS block FaceBook, Google and Twitter, so default.aspx is very slow to display because the webpage have to wait for loading FaceBook, Google +1 button code completely.
Is these a way to delay loading FaceBook, Google +1 button code and display the content default.aspx first?
You can download the code at http://dl.dropbox.com/u/209352/WebSite2.zip
==============================Default.aspx====================
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>
=========================MasterPage.master===================================
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div class="fb-like" data-href="http://www.myweb.com" data-send="false" data-layout="button_count"
data-width="120" data-show-faces="false" data-font="verdana">
</div>
<div>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.supercoolbookmark.com/"
data-count="horizontal" data-via="mycwcgr">Tweet</a><script type="text/javascript"
src="//platform.twitter.com/widgets.js"></script>
</div>
<div>
<g:plusone size="medium"></g:plusone>
</div>
<div>
<p>Hello, the world!</p>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
<div id="fb-root"></div>
<script> (function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));</script>
<!-- Place this render call where appropriate -->
<script type="text/javascript">
(function () {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</body>
</html>
You could add js.async = true; to the Facebook javascript - it will (like the similar line in the Google+ javascript) help with some newer browsers.
If that doesn't work, then the obvious option would be to use javascript to inject the three relevant divs after the page has finished loading. jQuery makes this very easy.
I have this in an ASP.Net Master Page:
<script language="javascript" type="text/javascript">
<asp:ContentPlaceHolder ID="scriptContentHolder" runat="server"></asp:ContentPlaceHolder>
</script>
But when I try to view the content page in design mode it tells me there is an error in the associated Master page because "scriptContentHolder" does not exist.
<asp:Content ID="scriptContent" ContentPlaceHolderID="scriptContentHolder" runat="server">
g_page = "mnuSurveys";
</asp:Content>
If I change the Master page to this:
<asp:ContentPlaceHolder ID="scriptContentHolder" runat="server"></asp:ContentPlaceHolder>
and the content page to this:
<asp:Content ID="scriptContent" ContentPlaceHolderID="scriptContentHolder" runat="server">
<script language="javascript" type="text/javascript">
g_page = "mnuSurveys";
</script>
</asp:Content>
Then all is cool. Why is this? The page compiles and executes just fine... but as above the designer squawks when placing ContentPlaceHolder controls within tags.
I had the same problem and solved it like that:
<%= "<script type=\"text/javascript\">" %>
jQuery(document).ready(function() {
// On document ready, execute this methods...
<asp:ContentPlaceHolder ID="jQueryOnDocReady" runat="server" />
});
<%= "</script>"%>
According to this MS Connect posting as of May '09, the
VS designer doesn't support controls
within script blocks. Alternately, you
can call
Page.ClientScriptManager.RegistgerClientScriptBlock
from content page
[sic]
So you'll have to use the second/work around method you posted.
this may be a bit off track. But I was having the same issue because i had some generic code i wanted in my Master page, and other more specific only on certain pages, here is my solution:
-In my .Master:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-X']);
_gaq.push(['_trackPageview']);
</script>
<asp:ContentPlaceHolder ID="PerPageScript" runat="server">
</asp:ContentPlaceHolder>
-In my .aspx:
<asp:Content ID="Content1" ContentPlaceHolderID="PerPageScript" runat="server">
<script type="text/javascript">
...
</script>
</asp:Content>