2011-06-20 10 views
2

私はいくつかの情報をキャプチャして、アプリケーションを完成させるサードパーティのウェブサイトにリダイレクトする短いアプリケーションフォームを持っています。CのリダイレクトでGoogleアナリティクスをトリガーする

Googleアナリティクス(およびGoogleコンバージョントラッカー)を使用して、当サイトのヒット数を監視しています。したがって、アナリティクスのJavascriptとリダイレクトを使用して「コンバージョンページ」に誘導する必要があります。残念ながら私のJavaScriptは呼び出されていません。

リダイレクトが発生する前にJavascriptが呼び出されるようにするにはどうすればよいですか?

<head runat="server"> 
<title></title></head><body> 
<script type="text/javascript" src="/scripts/Analytics.js"></script> 
<script type="text/javascript" src="/scripts/Analytics2.js"></script> 

<!-- Google Code for Filling out Form Conversion Page --> 

<script type="text/javascript"> 
    /* <![CDATA[ */ 
    var google_conversion_id = 964293672; 
    var google_conversion_language = "en"; 
    var google_conversion_format = "2"; 
    var google_conversion_color = "ffffff"; 
    var google_conversion_label = "H0y7CMi73wIQqOjnywM"; var google_conversion_value = 0; 
    /* ]]> */ 
</script> 

<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"> 
</script> 

<noscript> 
    <div style="display: inline;"> 
     <img height="1" width="1" style="border-style: none;" alt="" src="http://www.googleadservices.com/pagead/conversion/964293672/?label=H0y7CMi73wIQqOjnywM&amp;guid=ON&amp;script=0" /> 
    </div> 
</noscript> 

protected void Page_Load(object sender, EventArgs e) 
{ 
    if (!Page.IsPostBack) 
    { 
     Page.LoadComplete += new EventHandler(Page_LoadComplete); 
    } 
} 
void Page_LoadComplete(object sender, EventArgs e) 
{ 
    Response.Redirect("https://anotherwebsite.com/c/transint?uri_b=ia_86894"); 
} 

答えて

0

それを呼び出すために、他の公式の方法がありますされて見にGoogleアナリティクスSDKを使用することです私はので、私はちょうどJavaScriptはでリダイレクトを使用追加する必要がある第三トラッキングスクリプトを持っていますjQuery docReady関数です。

私はwindow.location.replace(...)を使用しました。ブラウジング履歴にリダイレクトページを置かないためです。

入力いただきありがとうございます@Aristos。

2

は、Google Analyticsのモバイルコードを取得し、ちょうどリダイレクトする前に、Googleアナリティクスへの内部直接電話をかけることができます。

ここのコード例を参照してください。 http://code.google.com/mobile/analytics/docs/web/

アナリ口座からga.aspxファイルをダウンロードし、背後にあるコードを使用して、Googleアナリティクスを呼び出すために、あなたのアカウントに応じて変更します。

ここでは、フォーカスする必要のあるコード部分について説明します。

string utmGifLocation = "http://www.google-analytics.com/__utm.gif"; 

     // Construct the gif hit url. 
     string utmUrl = utmGifLocation + "?" + 
      "utmwv=" + Version + 
      "&utmn=" + GetRandomNumber() + 
      "&utmhn=" + HttpUtility.UrlEncode(domainName) + 
      "&utmr=" + HttpUtility.UrlEncode(documentReferer) + 
      "&utmp=" + HttpUtility.UrlEncode(documentPath) + 
      "&utmac=" + account + 
      "&utmcc=__utma%3D999.999.999.999.999.1%3B" + 
      "&utmvid=" + visitorId + 
      "&utmip=" + GetIP(GlobalContext.Request.ServerVariables["REMOTE_ADDR"]); 

     SendRequestToGoogleAnalytics(utmUrl); 



    private void SendRequestToGoogleAnalytics(string utmUrl) 
    { 
     try 
     { 
      WebRequest connection = WebRequest.Create(utmUrl); 

      ((HttpWebRequest)connection).UserAgent = GlobalContext.Request.UserAgent; 
      connection.Headers.Add("Accepts-Language", 
       GlobalContext.Request.Headers.Get("Accepts-Language")); 

      using (WebResponse resp = connection.GetResponse()) 
      { 
       // Ignore response 
      } 
     } 
     catch (Exception ex) 
     { 
      if (GlobalContext.Request.QueryString.Get("utmdebug") != null) 
      { 
       throw new Exception("Error contacting Google Analytics", ex); 
      } 
     } 
    } 

多分これはGoogleのハックのように見えますが、わかりません。他の方法

http://code.google.com/apis/analytics/docs/tracking/home.html

関連する問題