how to include Google tracking code in html file

Discussion in 'ASP General' started by c676228, Mar 31, 2008.

  1. c676228

    c676228 Guest

    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
    c676228, Mar 31, 2008
    #1
    1. Advertising

  2. 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/markwilson/archive/2004/12/08/1939.aspx


    #Using Server-Side Include Directives (IIS 6.0)
    http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/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:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/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==?= <>
    >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
    >
    Steven Cheng [MSFT], Mar 31, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Cloud Burst
    Replies:
    11
    Views:
    1,014
  2. Ben Fidge
    Replies:
    2
    Views:
    487
    Ben Fidge
    Sep 5, 2006
  3. Tom
    Replies:
    8
    Views:
    650
    Adrienne Boswell
    Feb 13, 2007
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    886
    Andreas Bogenberger
    Feb 22, 2008
  5. JSH
    Replies:
    0
    Views:
    362
Loading...

Share This Page