0

背景

我有 AMP 页面,特别是AMP 故事,效果很好。此外,分析配置如下所示。音频、书挡进入和退出、页面视图等基本事件的分析......效果很好。

问题

然而,对于下面第二个代码中显示的书挡配置,我无法跟踪 AMP 从 JSON 生成的链接 a href 点击。我尝试了基本的选择器,但这也不起作用。当前书挡配置为 JSON。有没有办法跟踪书挡中链接的点击分析?该文档似乎更多地位于 AMP 页面上。由于书挡相对较新,我担心它有分析支持。

              <amp-analytics>
            <script type="application/json">
                                {
                              "vars": {
                                "storyURL": "${sourceUrl}",
                                "type": "story_analytics",
                                "templateId": "<%= @template_id %>",
                                "storyId": "<%= story.id %>",

                                "selectorGamedayURL": "amp-story-bookend",
                                "userId": "CLIENT_ID(site-user-id-cookie-fallback-name)"
                              },
                              "requests": {
                                "endpoint": "<%= AMP_ANALYTICS_URL %>",
                                "base": "${endpoint}"
                              },
                              "triggers": {
                 "anchorClicks": {
                    "on": "click",
                    "selector": "div.i-amphtml-story-bookend-article.i-amphtml-story-bookend-component",  // This doesn't work. the selector is correct but no analytics is sent 
                    "request": "event",
                    "vars": {
                      "event_id": "bookend-link-click"
                    }
                  },
                                "storyPageVisible": {
                                  "on": "story-page-visible",
                                  "request": "base",
                                  "extraUrlParams": {
                                    "event_id": "story_page_impression",

                                    "story_progress": "${storyProgress}",
                                    "story_page_index": "${storyPageIndex}",
                                    "story_page_count": "${storyPageCount}",
                                    "story_page_id": "${storyPageId}",
                                    "story_id": "${storyId}",
                                    "template_id": "${templateId}",
                                    "story_url": "${storyURL}",
                                    "timestamp": "${timestamp}",
                                    "type": "${type}",
                                    "user_id": "${userId}"
                                  }
                                },
                                "trackPageView": {
                                  "on": "visible",
                                  "request": "base",
                                  "extraUrlParams": {
                                    "event_id": "story_impression",

                                    "story_id": "${storyId}",
                                    "template_id": "${templateId}",
                                    "story_url": "${storyURL}",
                                    "timestamp": "${timestamp}",
                                    "type": "${type}",
                                    "user_id": "${userId}"
                                  }
                                },
                                "bookendEnter": {
                                  "on": "story-bookend-enter",
                                  "request": "base",
                                  "extraUrlParams": {
                                    "event_id": "story_bookend_enter",

                                    "story_progress": "${storyProgress}",
                                    "story_page_index": "${storyPageIndex}",
                                    "story_page_count": "${storyPageCount}",
                                    "story_page_id": "${storyPageId}",
                                    "story_id": "${storyId}",
                                    "template_id": "${templateId}",
                                    "story_url": "${storyURL}",
                                    "timestamp": "${timestamp}",
                                    "type": "${type}",
                                    "user_id": "${userId}"
                                  }
                                },
                                "bookendExit": {
                                  "on": "story-bookend-exit",
                                  "request": "base",
                                  "extraUrlParams": {
                                    "event_id": "story_bookend_exit",

                                    "story_id": "${storyId}",
                                    "template_id": "${templateId}",
                                    "story_url": "${storyURL}",
                                    "timestamp": "${timestamp}",
                                    "type": "${type}",
                                    "user_id": "${userId}"
                                  }
                                },
                                "audioMuted": {
                                  "on": "story-audio-muted",
                                  "request": "base",
                                  "extraUrlParams": {
                                    "event_id": "story_audio_muted",

                                    "story_id": "${storyId}",
                                    "template_id": "${templateId}",
                                    "story_url": "${storyURL}",
                                    "timestamp": "${timestamp}",
                                    "type": "${type}",
                                    "user_id": "${userId}"
                                  }
                                },
                                "audioUnmuted": {
                                  "on": "story-audio-unmuted",
                                  "request": "base",
                                  "extraUrlParams": {
                                    "event_id": "story_audio_unmuted",

                                    "story_progress": "${storyProgress}",
                                    "story_page_index": "${storyPageIndex}",
                                    "story_page_count": "${storyPageCount}",
                                    "story_page_id": "${storyPageId}",
                                    "story_id": "${storyId}",
                                    "template_id": "${templateId}",
                                    "story_url": "${storyURL}",
                                    "timestamp": "${timestamp}",
                                    "type": "${type}",
                                    "user_id": "${userId}"
                                  }
                                }
                              },
                              "transport": {
                                "beacon": true,
                                "xhrpost": true,
                                "useBody": true,
                                "image": false
                              }
                            }

            </script>
          </amp-analytics>

Bookend JSON 看起来像这样

              <amp-story-bookend layout=nodisplay>
            <script type="application/json">
              {
                "bookendVersion": "v1.0",
                "components": [
                {
          "type": "small",
          "title": "<%= title %>",
          "url": "<%= url %>",
          "category": "astronomy",
          "image": "<%= image_url %>"
          }
                ]
             }

            </script>
          </amp-story-bookend>
4

1 回答 1

2

您可以使用最近引入的触发器来跟踪这一点:story-bookend-click本 PR所示。

要使用它,只需将其添加到您的配置中:

              "trackBookendClicks": {
                "on": "story-bookend-click",
                "request": "click",
                "vars": {
                  "eventId": "clickOnBookend"
                }
              },

在您的请求中,您可以发送如下变量: "bookendClick": "${base}?bookendTargetHref=${storyBookendTargetHref}&bookendCardType=${storyBookendComponentType}&bookendCardPosition=${storyBookendComponentPosition}"

希望这可以帮助!

于 2019-10-18T15:44:04.393 回答