2013-05-15 27 views
0

嗨,大家好,我已经搜遍了问题,一直没能找到答案。我遇到了一个死胡同,我的公司分析团队开始担心他们收集的跟踪数据。Facebook的像按钮返回不正确的查询参数

我们目前使用sitecatalysts活动代码来跟踪和收集网站上的数据。有一个非常小的查询参数,随机放置在整个网站的链接上。

例如:?cmp=23-42

查询是否正确连接到共享按钮,然后从我可以告诉表单提交被传递。通过检查页面上的iframe,我在隐藏的表单字段中看到以下值。

<input type="hidden" autocomplete="off" name="href" value="http://my-site.com/some-post-or-article-name?cmp=23-42"> 

张贴后发送的标题。使用chrome开发工具。

fb_dtsg:AQCabg9S 
href:http://my-site.com/some-post-or-article-name?cmp=23-42 
ref: 
nobootload: 
action:like 
comment_text:test posts 
comment:test posts 
__user:181... 
__a:1 
__dyn:7w 
__req:7 
phstamp:165816797981035783273 

当我发布喜欢和任何意见,我想要的,我打开Facebook,并点击我刚刚发布的链接。我得到我的独特的跟踪查询取代facebook查询参数。

http://my-site.com/some-post-or-article-name?fb_action_ids=4184...&fb_action_types=og.likes&fb_source=aggregation&fb_aggregation_id=2883...

发生这种情况的每一篇文章和事件,我们已经列举了目前在60K范围内的某处,而这正是我的问题所在。所以我的问题是...

有没有在facebook文档中提到我缺少的东西,比如向我的fbml标签添加属性,看起来像query="cmp=23-42&more_stuff=more-custom-stuff"?所以,当添加我的独特查询参数时,可以自动附加到facebook查询参数的末尾。

有没有人遇到过这个问题,你是怎么解决的?

如果我无法使用自定义跟踪,是否有任何有创意的方式将关联的fb_action_ids或fb_aggregation_id与自定义广告系列代码关联起来?

是否有解决方法?

有关我们可以共享的网络应用程序的更多信息。 平台:回报率(我愿意使用该解决该问题的宝石,如果有任何可用的)

+0

的[可能重复摆脱Facebook的共享/喜欢的网址查询(通过mod \ _rewrite)](http://facebook.stackoverflow.com/questions/12081298/get-rid-of-facebook-shared-liked-url-query-via-mod-rewrite) – Igy

+0

服务器是nginx和phusion乘客不是apache,我们无法访问mod_rewrite –

回答

0

ref选项允许用户自定义数据追加到位于fb_ref PARAM返回的查询字符串。

发现这里 https://developers.facebook.com/docs/reference/plugins/like/

不幸的视线通过一个onload方法催化剂的标签,这是不是非常有帮助,因为它处理的数据自动上报脚本查找在URL活动代码。这里有一些有用的js是我从fb_ref参数中提取的。根据需要随意修改。

facebookCustomQueryString: function(){ 
if(window.location.href.indexOf('fb_ref=') == -1) return; 
var location = window.location.href, 
    params = location.split('?').pop().split('&'), 
    refCode, iframe, container; 

for(var i=0, m=params.length; i<m; i++){ 
    if(params[i].indexOf('fb_ref') > -1){ 
    var ref = params[i]; 
    refCode = ref.replace('fb_ref=',''); 
    break; 
    } 
} 
} 

解释::

  1. 的首要条件返回该功能的,如果fb_ref=是不是在URL

  2. 下设置一些局部变量(我没有想继续写window.location所以我抓住了这个)

  3. 循环params数组,找到我的匹配并删除[键]。将值存储到refCode变量中。

这就是您获取您的价值所需的一切。我敢肯定有更优雅的解决方案,但是这个脚本在jQuery加载之前运行。

如果你在我的位置上,仍然需要触发为中心催化剂码或不管它是你的使用跟踪,添加以下上面的方法。这将在页面上创建一个iframe,并将其源代码设置为基本url以及您最初需要返回的任何自定义查询。

iframe = document.createElement('iframe'); 
iframe.setAttribute('class',''); // I added absolute positioning -9999px left/top .01em height/width 
iframe.setAttribute('id',''+Math.random()); // any random id name here optional for some browsers 
iframe.setAttribute('src',location.split('?').shift()+'?'+refCode); 
iframe.setAttribute('onload', 'foo.remove(this)'); // added the onload function to remove the iframe, reporting should be done by this time. Make sure your method foo.remove() is accessible in the DOM 

container = document.createElement('div'); // create a container to hold the iframe, optional, depends on your site markup 
container.setAttribute('id',''+Math.random()); // another random id 
document.getElementsByTagName('body')[0].appendChild(container); // add the container to the body 
container.appendChild(iframe); // add the iframe to the container 

最后,我的删除方法..再次填写可以根据需要进行修改。

remove: function(ui){ 
ui.parentNode.innerHTML = ''; 
ui.remove(ui.selectedIndex); 
} 

对于IE浏览器,您可能需要稍微修改remove方法。我没有测试过这些,但你可以尝试

​​

我希望这是在我的情况的人有帮助...

相关问题