Google Analytics 中的自定义页面标记

发布于 2024-09-04 18:58:40 字数 251 浏览 8 评论 0原文

我想在我的 Google Analytics(分析)报告页面中使用与我拥有的 URL 不同的自定义页面标签。

例如,

  • 实际 URL:/news/today_news.php
  • Google Analytics 上的页面标签:/news/today_news.php/Category.News/TodayNews

如何使用 Google Analytics 数据收集 API 制作自定义页面标签?

I want to have custom page tags, which are different from URLs I have, in my Google Analytics report page.

For instance,

  • Actual URL : /news/today_news.php
  • Page tag on Google Analytics : /news/today_news.php/Category.News/TodayNews

How can I make the custom page tag with Google Analytics Data Collection API?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不乱于心 2024-09-11 18:58:40

有几种简单的方法可以做到这一点(更改 GA 跟踪网站上给定页面的 GA 默认名称)。

我。将自定义名称作为参数传递给“_trackPageview”

这可能是最常见的方法,也可能是最简单的方法。

主要的 GA 方法 _trackPageview 通常在不传入任何参数的情况下调用,即 pageTracker._trackPageview()。

但是,您可以传入一个字符串作为您希望用于该页面的名称。换句话说,在您想要更改其名称的每个页面上找到对 _trackPageview 的调用,并将新名称作为字符串插入到括号之间,例如,

pageTracker._trackPageview("the_new_name_for_this_page");

严格来说,您传入的参数实际上会将请求 URI 值更改为您传入的字符串。

要验证:在您的 GA 帐户中打开相关配置文件,然后单击左侧菜单中的“内容”,然后单击“热门内容”。这将导致在 GA 浏览器的主查看窗口中呈现一个表格。该表最左边的列显示页面(实际上是请求 URI)。检查此列的内容以查找重命名的页面。

GA 使用两种方式来识别报告中“内容”标题下的页面 - 通过请求 URI页面标题。例如,当您单击“顶部内容”时显示的表格在最左侧的列中显示前者(该列名为“页面”)。另一方面,当您单击“顶部内容”正下方的报告时显示的表格Content”,即“按标题显示内容”,按标题显示页面(“页面标题”是最左侧的列标题)。这里的“页面标题”仅指页面头部标题标签之间出现的任何内容。换句话说,我刚才提到的两种技术不会影响页面的标题(“按标题显示内容”的报告不会改变)。

二.使用“过滤器”

例如,GA 有一个名为“搜索和替换”的自定义过滤器类型过滤器,这可能是 GA 中最好的选择过滤器类型。这种技术的优点是它不需要页面中的任何代码。

点击“分析设置”> “配置文件设置”(橙色导航栏的左上角),然后滚动直到看到“应用于此配置文件的过滤器”;单击最右侧的“+ 添加过滤器”。由于每种过滤器类型(预定义与自定义,而自定义过滤器类型又由六种不同的过滤器类型组成)的设置不同,因此最好将您推荐给相关的 GA 资源

III.使用“自定义变量”

这是最需要付出努力的技术(尽管仍然不难);它也是三种技术中最复杂的;例如,使用简历,您可以将给定页面重新映射到多个名称,这在您想要对内容进行分层分组时非常有用。例如,您可能希望为电子商务网站中的特定页面提供三个标签,以描述商品类别、性别和品牌,例如“鞋类”、“男士”和“梯瓦”或“鞋类/男士” /梯瓦”。例如,

pageTracker._setCustomVar(
        1,                     // 'Index' for this CV (an integer, 1-5)
       "MerchandiseCategory",  // 'Name' for this CV
       "Footwear",             // 'Value'--set upon call to _trackPageview
        3,                    // 'Scope' an integer, 1-3, use '3' here because
                             //  i have scoped this particular CV to 'page level' 
                             //  (1 and 2 are for visitor and session, respectively)
)

上面的代码初始化了 CV,因此需要将其放置在调用 _trackPageview 之前,因为正是该调用设置了该变量的值。

完成此操作并为您的简历记录数据后,您就可以开始使用它们了。请记住,简历本身并不是报告,而不是真正的“变量”,这要好得多,因为您可以通过 GA 中的“自定义报告”功能使用它们来创建您想要的任何报告。

例如,单击 GA 浏览器左侧导航面板中间的“自定义报告”(选择特定配置文件后)。然后单击“自定义报告”,然后单击右上角的“+ 创建新的自定义报告”。现在单击“维度”(左侧的绿色导航“按钮”),然后单击“访客”。滚动浏览“访客”维度的值,在列表末尾附近,您将看到为自定义变量保留的其他值。例如,如果您定义了一个名为“访客类型”的简历,其可能值为“注册用户”和“潜在客户”,则该简历将显示在此处,因此可供您用来创建自定义报告。

以下是我认为 Google Analytics(分析)团队最有用的解释自定义变量。

这是一篇精彩的博文,来自简历方面的 GA 顾问。

There are several straightforward ways to do this (change the GA default name for a given page on your GA-tracked Site).

I. Passing the custom name in as a parameter to "_trackPageview"

This is probably the most common way to do this and probably the most straightforward.

The primary GA Method, _trackPageview, is usually called without passing in any parameters, i.e., pageTracker._trackPageview().

You can however, pass in a string for the name you wish to use for that page. In other words, find the call to _trackPageview on each page whose name you wish to change and insert your new name as a string between the parentheses, e.g.,

pageTracker._trackPageview("the_new_name_for_this_page");

Strictly speaking, the parameter you pass in actually changes the Request URI value to the string you passed in.

To verify: open the relevant Profile in your GA account, then click "Content" in the left-hand side menu, then "Top Content." This will cause a Table to render in the main viewing window of the GA Browser. The left-most column of that Table displays the Page (actually the Request URI). Check the contents of this column for your re-named pages.

GA uses two ways to identify pages in their Reports under the "Content" rubric--by Request URI and by Page Title. The Table displayed when you click on "Top Content" for instance, shows the former in the left-most column (the column is named "Page.") On the other hand, the Table displayed when you click the Report just below "Top Content", which is "Content by Title", shows pages by their title ("Page Title" is the left-most column header). "Page Title" here just refers to whatever appears between the title tag in the head of your page. In other words, the two techniques i just mentioned will not affect the Page's Title (the report "Content by Title" will not be changed).

II. Use a "Filter"

For instance, GA has a custom filter type called a "search and replace" filter, which is probably the best option among the GA filter types. The advantage of this techniques is that it doesn't require any code in the page.

Click "Analytics Settings" > "Profile Settings" (top left in the orange navigation bar), then scroll until you see "Filters Applied to this Profile"; click "+ Add Filter" to the far right. Because each filter type (pre-defined versus custom, which in turn is comprised of six different filter types) is set differently, it's probably best if i just refer you to a relevant GA resource.

III. Use "Custom Variables"

This is technique requires the most effort (though it's still not difficult); it's also the most sophisticated of the three techniques; for instance, using CVs you can re-map a given page to more than one name, which is useful when you want to group your content hierarchically. So for instance, you might wish give a particular page in your e-commerce Site three labels, to describe merchandise category, sex, and Brand, e.g., "Footwear", "Men's", and "Teva", or "Footwear/Mens/Teva". So for instance,

pageTracker._setCustomVar(
        1,                     // 'Index' for this CV (an integer, 1-5)
       "MerchandiseCategory",  // 'Name' for this CV
       "Footwear",             // 'Value'--set upon call to _trackPageview
        3,                    // 'Scope' an integer, 1-3, use '3' here because
                             //  i have scoped this particular CV to 'page level' 
                             //  (1 and 2 are for visitor and session, respectively)
)

The code above initializes the CV, so it needs to be placed before your call to _trackPageview, because it's that call that sets the value of this variable.

After you've done this, and data has been recorded for your CVs, then you can begin using them. Remember, CVs are not Reports per se, rather than are indeed 'variables' which is much better because you can use them to create any reports you wish through the "Custom Reporting" feature in GA.

For instance, click "Custom Reporting" in the middle of the left-hand navigation panel in the GA Browser (once you have selected a particular profile). Then click "Custom Reports" then "+ Create new custom report" in the top right hand corner. Now click "Dimensions", the green navigation 'button' on the left-hand side, then click "Visitors." Scroll through the values for the 'Visitor' Dimension, and near the end of the list you will see additional values reserved for Custom Variables. If for instance, you had defined a CV called "Visitor Type" with possible values of "RegisteredUser" and "Prospect", that CV would show up here and therefore be available for you to use to create Custom Reports.

Here's what i believe is the Google Analytics Team's most useful explanation of Custom Variables.

And here is an excellent Blog post from a GA Consultant on CVs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文