惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - Iceting

性能分析工具 广告推广测试 背压(Backpressure)机制 工作相关资料 ElasticSearch问题记录 bfrd collector性能排查 Ubuntu13.10下安装HADOOP Hadoop各商业发行版之比较 linux编程学习顺序 作为程序员,你最常上的网站是什么 Java 学习 swing 应该学习到什么程度? JAVA学习之路 Java中的字符串 2012—IT职场繁荣重现 Best Practices for Exception Handling 散列表(哈希表)(四)散列表上的运算 散列表(哈希表)(二)散列函数的构造方法 散列表(哈希表)(三)处理冲突的方法 散列表(哈希表)(一)散列表的概念
TapTap推广统计逻辑
Iceting · 2017-02-06 · via 博客园 - Iceting

  当我们在Taptap上访问某款游戏时,比如https://www.taptap.com/app/34762,taptap会记录下这次访问,它是怎么做的呢。

  首先,用记事本打开这个网址,在head部分看到下面这行引用,继续打开这个js

          <script type="text/javascript" src="https://static.taptapdada.com/scripts/tracker.js" async></script>          

(function (window, document) {
    function createHttpRequest() {
        if (window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        else if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        }
    }

    function LogTracker(host, project, logstore) {
        this.uri_ = 'https://' + project + '.' + host + '/logstores/' + logstore + '/track?APIVersion=0.6.0';
        this.params_ = [];
        this.httpRequest_ = createHttpRequest();
    }

    LogTracker.prototype = {
        push: function (key, value) {
            if (!key || !value) {
                return;
            }
            this.params_.push(key);
            this.params_.push(value);
        },
        logger: function () {
            var url = this.uri_;
            var k = 0;
            while (this.params_.length > 0) {
                if (k % 2 == 0) {
                    url += '&' + encodeURIComponent(this.params_.shift());
                }
                else {
                    url += '=' + encodeURIComponent(this.params_.shift());
                }
                ++k;
            }
            try {
                this.httpRequest_.open("GET", url, true);
                this.httpRequest_.send(null);
            }
            catch (ex) {
                if (window && window.console && typeof window.console.log === 'function') {
                    console.log("Failed to log to log service because of this exception:\n" + ex);
                    console.log("Failed log data:", url);
                }
            }

        }
    };
    window.Tracker = LogTracker;
})(window, document);

这里定义了LogTracker这样日志跟踪类,并提供了参数供调用方填写,回到之前的html代码,寻找这个类调用的地方

    <script>
        $(function () {
            var logger = new window.Tracker('cn-beijing.log.aliyuncs.com', 'tap-snow', 'logs');
            logger.push('platform', 'web');
            logger.push('device', navigator.userAgent);
            logger.push('type', 'pageView');
            logger.push('paramUrl', 'https://www.taptap.com/app/34762');
            logger.push('paramReferer', document.referrer);
            logger.logger();
        });
    </script>

这里看到页面访问时,会访问 https://tap-snow.cn-beijing.log.aliyuncs.com/logstores/logs/track?APIVersion=0.6.0&platform=web&device=...