1

AMPページを実装しました。エラーなしでインデックスに登録され、Google検索に表示されます。訪問者がGoogle SERPのリンクをクリックすると、organic/googleから参照されるように、Googleアナリティクス(キャッシュされたページを含む)に表示されます。しかし、訪問者がそのAMPページ上のリンクをクリックすると、参照者は時々referral/ampprogect.orgと予想され、多くの場合direct/noneとなります。
もちろん、amp-analyticsが設定されています。
私は、キャッシュされたページからのクリックに応答してAMPページがメインサーバーから提供されたときに、direct/noneが表示されると考えます。
数日前にAMPが公開されましたが、今までにすべてが発見されているわけではありません。
意味がありますか?
アンプ-分析は非常に基本的な方法で実装されてGoogleアナリティクスは、キャッシュされたアンプページのクリックを直接/なしとして表示します

<amp-analytics type="googleanalytics"> 
<script type="application/json"> 
{ 
    "vars": { 
    "account": "UA-XXXXX-Y" //real account id for sure 
    }, 
    "triggers": { 
    "trackPageview": { 
     "on": "visible", 
     "request": "pageview" 
    } 
    } 
} 
</script> 
</amp-analytics> 

私はAMPのためのGoogleタグマネージャを設定し、同じ結果と

<amp-analytics config="https://www.googletagmanager.com/amp.json?id=GTM-zzzzzz&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics> 

amp-analiticsブロックを変更

更新。
非アンペアにキャッシュされAMPページ(つまりhttps://google.com/mydomain-com.cdn...である)からのクリックはdirect/noneを示し(つまりhttps : //mydomain.com/amp/something.aspxある)referral/ampproject.orgを示し、非キャッシュされたAMPをクリックしてください。

+0

この[ブログ](http://blog.analytics-toolkit.com/2015/google-analytics-direct-none-source/)に基づいて、ユーザーがあなたのサイトに移動し、Googleアナリティクスが知りませんユーザーはどこから来たので、セッションは(直前のキャンペーンデータがそのクッキーに存在していない限り)「直接/なし」としてマークされます。 – abielita

答えて

0

this great postのおかげで、何が間違っているのか理解し、そのアイデアを.NETに適用しました。主なアイデアはamp-analytics構成オブジェクト(JSONフォーマット)をキャッチし、それを自分自身(clientIdの内部)に置き換えることです。
まず私はweb.configでそれを登録次HttpHandler

''//.VB 
Namespace AmpHandlers 
    Public Class AmpConfig 
     Implements IHttpHandler 

     Private Const unixStart As DateTime = #1/1/1970# ''//start of epoc 

     Public ReadOnly Property IsReusable As Boolean Implements IHttpHandler.IsReusable 
      Get 
       Return False 
      End Get 
     End Property 

     Public Sub ProcessRequest(context As HttpContext) Implements IHttpHandler.ProcessRequest 
      context.Response.Clear() 
      ''//ecpected request 
      ''// https : //mydomain.com/gtm-amp.json?id=GTM-zzzzzz&gtm.url=SOURCE_URL 
      If String.IsNullOrEmpty(context.Request.QueryString("id")) OrElse context.Request.QueryString("id") <> "GTM-zzzzzz" Then 
       ''//no answer 
       context.Response.End() 
       Return 
      End If 
      Dim clientId As String = "" 
      If context.Request.Cookies("_ga") IsNot Nothing Then 
       Dim ga As String = context.Request.Cookies("_ga").Value ''//GA1.2.12321354.1507250223 
       clientId = Regex.Match(ga, "(\d+?\.\d+?$)").Groups(1).Value 
      Else 
       Dim rand As New Random() 
       ''//Majic 2147483647 is upper limit of Google's random part of _ga cookie 
       ''//The second part is Unix time, in seconds 
       clientId = rand.Next(2147483647) & "." & CInt(DateTime.UtcNow.Subtract(unixStart).TotalSeconds) 
      End If 
      ''//Set cookie and response headers 
      context.Response.ContentType = "application/json" '; charset=UTF-8 
      context.Response.SetCookie(New HttpCookie("_ga") With {.Value = "GA1.2." & clientId, 
       .Path = "/", .Domain = context.Request.Url.Host, .Expires = DateTime.UtcNow.AddYears(2) 
             }) 
      context.Response.AddHeader("Access-Control-Allow-Origin", "https://mydomain-com.cdn.ampproject.org") 
      context.Response.AddHeader("Access-Control-Expose-Headers", "AMP-Access-Control-Allow-Source-Origin") 
      context.Response.AddHeader("AMP-Access-Control-Allow-Source-Origin", "https://" & context.Request.Url.Host) 
      context.Response.AddHeader("Access-Control-Allow-Source-Origin", "https://" & context.Request.Url.Host) 
      context.Response.AddHeader("Access-Control-Allow-Credentials", "true") 
      context.Response.AddHeader("Content-Disposition", "attachment; filename=""GTM-NZPM27T.json""") 
      context.Response.AddHeader("cache-control", "no-cache, no-store, must-revalidate") 

      ''//https://www.googletagmanager.com/amp.json?id=GTM-zzzzzz&gtm.url=SOURCE_URL response is saved locally and edited 
      ''//possibly it is not the best colution 
      Dim sr As New IO.StreamReader(context.Server.MapPath("~/amp-gtm.config")) 
      Dim str As String = sr.ReadToEnd() 
      str = str.Replace("[[clientId]]", clientId) 
      context.Response.Write(str) 
      context.Response.Flush() 
      context.Response.End() 
     End Sub 
    End Class 
End Namespace 

を作成しました。

<handlers> 
    <add name="amp-gtm" verb="GET" path="gtm-amp.json" type="AmpHandlers.AmpConfig" resourceType="Unspecified"/> 
</handlers> 

最後にamp-analyticsタグに入れます。

<amp-analytics config="https : //mydomain.com/gtm-amp.json?id=GTM-zzzzzz&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics> 

今すぐにキャッシュされ、非キャッシュAMPページからすべてのクリックはorganic/googleを示しました。

関連する問題