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

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

问题描述

Google Analytics中是否有支持的方式来跟踪广告系列,而无需使用查询字符串参数。



在Google Analytics中,您可以使用查询字符串参数标记您网站的链接,例如 utm_campaign utm_medium ,其中包含有关广告系列的信息,以便可以跟踪这些信息。



Google实际上有一个线上工具来帮助创建这样的链接。例如,如果StackOverflow在专家交易所上做广告,他们可能会有这样的链接:



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网站)。使用这样的URL给我的网站提供一个链接:

  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:campaignSource,
utm_medium:campaignMedium,
utm_campaignName:campaignName
});
pageTracker._trackPageview();

重要提示:_setCampaignData方法不会实际存在。这只是'伪代码',因为我理想上能够做到这一点。



有没有人成功地做过这样的事情? / p>

解决方案

_set campaignParams



您的理论_setCampaignData终于存在, [_ set,campaignParams,...]



的形式如果您有办法以编程方式注入想要设置的值(例如,通过重定向上的cookie设置,或在服务器端设置并打印到页面上),可以使用 _set API来硬编码您想要设置的广告系列参数。

格式为:

  _gaq.push( ['_set','campaignParams',
'utm_campaign = CAMPAIGN& utm_source = SOURCE& utm_medium = MEDIUM']);

因此,使用您的原始示例:

  var campaignMedium =<%= ViewData.Model.CampaignMedium%>; 
var campaignSource =<%= ViewData.Model.CampaignSource%>;
var campaignName =<%= ViewData.Model.CampaignName%>;
_gaq.push(['_ set','campaignParams',
'utm_campaign ='+ campaignName +'& utm_source ='+ campaignSource +'& utm_medium ='+ campaignMedium]);



更新2017



此答案详细说明了如何使用新的Google Analytics库analytics.js / Universal Analytics完成此操作。

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?

解决方案

_set campaignParams

Your theoretical "_setCampaignData" finally exists, in the form of ["_set","campaignParams",...]

If you have a way to programmatically inject the values you'd like to set (for example, set by a cookie on a redirect, or on the server side and printed onto the page), you can use the _set API to hard-code the campaign params that you'd like to set.

The format for that is just:

_gaq.push(['_set', 'campaignParams', 
'utm_campaign=CAMPAIGN&utm_source=SOURCE&utm_medium=MEDIUM']);

So, using your original example:

 var campaignMedium = <%= ViewData.Model.CampaignMedium %>;
 var campaignSource = <%= ViewData.Model.CampaignSource %>;
 var campaignName = <%= ViewData.Model.CampaignName %>;
 _gaq.push(['_set', 'campaignParams', 
'utm_campaign=' + campaignName +  '&utm_source=' + campaignSource +'&utm_medium=' + campaignMedium]);

Update 2017

This answer details how to accomplish this with the newer Google Analytics library, analytics.js/Universal Analytics.

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

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