Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > how to include Google tracking code in html file

Reply
Thread Tools

how to include Google tracking code in html file

 
 
c676228
Guest
Posts: n/a
 
      03-31-2008
Hi all,
I put GA's tracking code in a html file called ga_track.html and include in
any *.asp file before the end of the </body>, see below:
<!--#Include Virtual="/TISMSDE/GA_track.html" -->
</body>
<!-- Google Analytic Tracking Code :GA_track.html-->
<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">
var pageTracker = _gat._getTracker("UA-2356948-8");
pageTracker._initData();
pageTracker._trackPageview();
</script>

everything looks Ok and these code could be seen when you view any page's
source code. but my question is how we should include this piece of code in
*.html
file. In what way we include this file(or *.js file), the code could be seen
when you open view source in browser instead of just one line code
<!--#Include Virtual="/TISMSDE/GA_track.html" -->
or <<script type="text/javascript" src="/tismsde/ga_track.js"></javascript>

since I am afaid of GA cannot work correctly without seeing the piece of
code directly in the browser.

Any recommendation?
--
Betty
 
Reply With Quote
 
 
 
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      03-31-2008
Hi Betty,

The following directives you used are called "Server side include"
directives.

<!--#Include Virtual="/TISMSDE/GA_track.html" -->

they're not standard html features(that's why your plain html page will not
parse them and the directive is directly flushed into client-side/you can
see it in page source).

to make the directive get parsed(and load the certain include file content
into page), you need to make the page be processed by the server-side
include extension in webserver. For IIS server, the extension is
"ssinc.dll". By default, the following extensions are mapped to it :

*.stm
*.shtm
*.shtml

So you can consder the following approaches for your case:

1. change htm file to .stm(or other extension above) in your IIS server

2. Or you can change the htm/html file extensions to be mapped to the
"ssinc.dll" in IIS

BTW, make sure that server-side incllude is enabled in your webserver(for
IIS 6).

Here are some other reference introducing using server-side includes:


#Using server side includes in web pages
http://blogs.conchango.com/markwilso...2/08/1939.aspx


#Using Server-Side Include Directives (IIS 6.0)
http://www.microsoft.com/technet/pro.../Library/IIS/e
ced0b89-e052-42ff-baa8-751dd191c3b5.mspx?mfr=true


#WWW FAQs: How do I include one HTML file in another?
http://www.boutell.com/newfaq/creating/include.html


Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
http://www.velocityreviews.com/forums/(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

>X-WBNR-Posting-Host: 64.85.224.157
>From: =?Utf-8?B?YzY3NjIyOA==?= <(E-Mail Removed)>
>Subject: how to include Google tracking code in html file
>Date: Sun, 30 Mar 2008 17:49:00 -0700


>
>Hi all,
>I put GA's tracking code in a html file called ga_track.html and include

in
>any *.asp file before the end of the </body>, see below:
><!--#Include Virtual="/TISMSDE/GA_track.html" -->
></body>
><!-- Google Analytic Tracking Code :GA_track.html-->
><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">
>var pageTracker = _gat._getTracker("UA-2356948-8");
>pageTracker._initData();
>pageTracker._trackPageview();
></script>
>
>everything looks Ok and these code could be seen when you view any page's
>source code. but my question is how we should include this piece of code

in
>*.html
>file. In what way we include this file(or *.js file), the code could be

seen
>when you open view source in browser instead of just one line code
><!--#Include Virtual="/TISMSDE/GA_track.html" -->
>or <<script type="text/javascript" src="/tismsde/ga_track.js"></javascript>
>
>since I am afaid of GA cannot work correctly without seeing the piece of
>code directly in the browser.
>
>Any recommendation?
>--
>Betty
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
/* #include <someyhing.h> */ => include it or do not include it?That is the question .... Andreas Bogenberger C Programming 3 02-22-2008 10:53 AM
include HTML file in another HTML file Tom HTML 8 02-13-2007 03:25 PM
Tracking Someone Tracking Me Edw. Peach Computer Security 4 07-07-2005 05:50 PM
is there a way to "include" source file B.html in source file A.html? Cloud Burst HTML 11 01-09-2004 02:49 AM



Advertisments