在没有查询字符串参数的情况下使用 Google Analytics 跟踪广告系列? [英] Track campaigns with Google Analytics without query string parameters?

查看:24
本文介绍了在没有查询字符串参数的情况下使用 Google Analytics 跟踪广告系列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Analytics 中是否有一种无需使用查询字符串参数即可跟踪广告系列的支持方法.

在 Google Analytics(分析)中,您可以标记链接到您的网站带有查询字符串参数,例如 utm_campaignutm_medium,它们携带有关活动的信息,以便对其进行跟踪.

Google 实际上有一个在线工具 帮助创建此类链接.

例如,如果 StackOverflow 在 Experts Exchange 上做广告,他们可能有这样的链接:

http://www.stackoverflow.com/?utm_source=expertexchange&utm_medium=banner&utm_campaign=a-better-expert-exchange

出于多种原因,我不希望这些看起来笨拙的参数出现在我的 URL 中:

  • 我想鼓励推特,而长链接会阻止这种行为
  • 我不希望人们用广告系列 ID 为它们添加书签
  • 我希望人们看到一个干净的 URL
  • 我不希望搜索引擎将这些链接编入索引.
  • 我希望完全控制发送给 Google Analytics 的参数 - 而不是让我的合作伙伴弄乱他们访问我网站的 URL

我不久前试图找到一种可以设置这些参数的方法.Google 有一个页面,乍一看似乎是解决方案,但实际上不是.该页面描述了如何将查询字符串参数的名称更改为其他名称 - 例如使用 src 而不是 utm_source 你会运行:

 pageTracker._setCampSourceKey("src");

我似乎真的不明白为什么他们不能轻松地实际显式设置 utm_source 键的值 - 而不仅仅是为其设置替代参数名称.

我记得前段时间发现有人有一种令人讨厌的黑客行为,但我现在似乎找不到了.我似乎记得,不管是谁拿了分析代码的副本,基本上把它分支出来并对其进行了黑客攻击.这对我来说不是一个好的解决方案!

是否有一种官方支持的方式来做到这一点,而没有某种讨厌的重定向.

简而言之,我想做这样的事情(ASP.NET MVC 站点).使用如下网址为 partnet 提供指向我网站的链接:

 http://www.example.com/?cid=2dae88a8-66b1-475d-8a35-2978bd1a158c

在我的 MVC 页面的控制器中,我会找出这个 GUID 与什么活动相关,并设置模型状态.注意:这为我提供了一个优势,即我可以更改活动参数而无需重新发布 URL.

在页面本身中,我会这样做:

var campaignMedium = <%= ViewData.Model.CampaignMedium %>;var CampaignSource = <%= ViewData.Model.CampaignSource %>;var CampaignName = <%= ViewData.Model.CampaignName %>;pageTracker._setCampaignData({utm_source:活动来源,utm_medium: 活动媒体,utm_campaignName:活动名称});pageTracker._trackPageview();

重要提示:此 _setCampaignData 方法实际上并不存在.这只是我理想中想要做的伪代码".

有没有人成功地做到过这样的事情?

解决方案

使用 push(['_set', 'campaignParams',... 似乎只适用于 遗留库 ga.js.

使用 analytics.js,您需要单独指定活动参数.例如

ga('set', 'campaignName', 'TheCampaignName...');ga('set', 'campaignSource', 'someCampaignSource');ga('set', 'campaignMedium', 'email');

https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#campaignName

Is there a supported way in Google Analytics to track a campaign without having to use query string parameters.

In Analytics you can tag a link to your site with query string parameters such as utm_campaign and utm_medium which carry information about the campaign so that they can be tracked.

Google actually has an online tool to help in the creation of such links.

For instance if StackOverflow was advertising on Experts Exchange they may have a link like this :

http://www.stackoverflow.com/?utm_source=expertexchange&utm_medium=banner&utm_campaign=a-better-expert-exchange

For many reasons I don't want these clumsy looking parameters appearing in my URLS :

  • I want to encourage twittering, and long links discourage this
  • I dont want people bookmarking them with campaign IDs in
  • I want people to see a clean URL
  • I dont want search engines indexing these links.
  • I want full control about what parameters are sent to google analytics - and not leave it up to my partners to mess up the URLs they access my site with

I looked a while ago to try to find a way wherein you could set these parameters. Google has a page which at first glance looks like the solution, but actually isn't. That page describes how you can change the names of the query string parameters to something else - for instance to use src instead of utm_source you would run :

 pageTracker._setCampSourceKey("src");     

I really cannot seem to figure out why they don't make it easy to actually explicitly set the value of the utm_source key - and not just set up an alternative parameter name for it.

I remember a while back finding someone who had a kind of nasty hack, but I cant even seem to find that now. I seem to recall though that whoever it was took a copy of the analytics code and essentially branched it off and hacked at it. This is not a good solution for me!

is there an officially supported way of doing this at all, without some kind of nasty redirects.

In a nutshell I want to do something like this (ASP.NET MVC site). Give a partnet a link to my site with a URL like this :

 http://www.example.com/?cid=2dae88a8-66b1-475d-8a35-2978bd1a158c

In the controller for my MVC page I would find out what campaign this GUID related to, and set the model state. Note: this gives me the advantage that i can change the campaign parameters without having to reissue the URL.

In the page itself I would then do this:

var campaignMedium = <%= ViewData.Model.CampaignMedium %>;
var campaignSource = <%= ViewData.Model.CampaignSource %>;
var campaignName = <%= ViewData.Model.CampaignName %>;

pageTracker._setCampaignData({
    utm_source: campaignSource,
    utm_medium: campaignMedium,
    utm_campaignName: campaignName
});
pageTracker._trackPageview();

IMPORTANT: This _setCampaignData method DOES NOT ACTUALLY EXIST. This is just 'pseudo code' for what I'd ideally like to be able to do.

Has anyone successfully managed to do anything like this?

解决方案

The solution using push(['_set', 'campaignParams',... seems only to work for the legacy library ga.js.

Using analytics.js you need to specify the campaign param separately. E.g.

ga('set', 'campaignName', 'TheCampaignName...');
ga('set', 'campaignSource', 'someCampaignSource');
ga('set', 'campaignMedium', 'email');

https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#campaignName

这篇关于在没有查询字符串参数的情况下使用 Google Analytics 跟踪广告系列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆