简体   繁体   English

移动页面上的像素跟踪失败

[英]Pixel tracking failing on mobile page

i have a pixel tracking on a webpage, it is working nice for many time, but yesterday i find that is not working well on mobile page m.url.com, instead of www.url.com. 我在网页上进行了像素跟踪,很多时候效果很好,但是昨天我发现在m.url.com而不是www.url.com的移动页面上效果不佳。

Mobile page only reload the header the first time you load the page, so i change the tracking to be called on a live event. 移动页面仅在您第一次加载页面时才重新加载标头,因此我将跟踪更改为在实时事件中调用。

Is working and it call the js where i calculate the browser, user_agent, etc to pass as query string in the pixel. 正在工作,它调用js,我在其中计算浏览器,user_agent等,以像素形式作为查询字符串传递。

This is the function on my Tracking JS class: 这是我的Tracking JS类上的函数:

/**
 * Web beacon with query string
 */
function getImage(query_string) {
    var image = new Image(1, 1);
    image.onload = function () {
        console.log(image);
    };
    image.error = function () {
        console.log('error');
    };
    image.onabort = function () {
        console.log('abort');
    };
    image.src = 'http://<myurl>/picture.gif?' + query_string;
}

When i call this function on m.url.com (mobile site), on chrome, the first time the page is loaded, the pixel works, after that, when i navigate the pixel only works on chrome, on other browsers like firefox and safari dont, all is working and the src callback the .onload function with the url of the image, no errors, no abort... 当我在chrome上的m.url.com(移动网站)上调用此函数时,第一次加载页面时,像素有效,此后,当我导航像素仅在chrome上有效时,在其他浏览器(如firefox和Safari浏览器不运行,一切正常,并且src使用图像的url回调.onload函数,没有错误,没有中止...

Maybe src only works 1 time at same class? 也许src在同一堂课上只能上1次课? Dont know, 不知道

Thx for help in advance. 提前寻求帮助。

It seems that the image is cached once and not requested anymore. 似乎该图像被缓存了一次,不再需要了。 Just add a timestamp to the image url: 只需将时间戳添加到图像网址:

image.src = 'http://<myurl>/picture.gif?_=' + (new Date()).getTime() + '&' + query_string;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM