1

その間ずっと、この現実的な Web サイト リダイレクト HTML/JavaScript コードを使用しています。

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="1;url=https://www.nosuchwebsite.com">
        <script type="text/javascript">
            window.location.href = "https://www.nosuchwebsite.com"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
        If you are not redirected automatically, follow the <a href='https://www.nosuchwebsite.com'>nosuchwebsite</a>
    </body>
</html>

ここで、リダイレクトの前に Google Analytics トラッキング コードを実行したいと考えています。

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxxx-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>

メタ「更新」が JavaScript トラッキング コードよりも早く実行される可能性があることは認識しています。メタ「更新」の前に実行するGoogle Analyticsトラッキングコードを作成する方法があるかどうか疑問に思っていました

4

2 に答える 2

0

または、メタ リフレッシュを使用せずに Javascript リフレッシュを使用し、メタ リフレッシュ<noscript>を適切な手段としてブロックに配置します。

于 2013-06-20T05:30:40.497 に答える