Home > Archive > ASP > March 2008 > how to include Google tracking code in html file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
how to include Google tracking code in html file
|
|
| c676228 2008-03-31, 4:00 am |
| 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
| |
| Steven Cheng [MSFT] 2008-03-31, 4:00 am |
| 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/markwils...12/08/1939.aspx
#Using Server-Side Include Directives (IIS 6.0)
http://www.microsoft.com/technet/pr...3/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:
msdnmg@microsoft.com.
========================================
==========
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.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/subscript...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==?= <betty@newsgroup.nospam>
>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
>
|
|
|
|
|