Authored by huzhiming

feat(oCPC搜索推广): 推广链接转化数据发送给百度服务器,埋点:OCPC推广链接打开并完成注册进行数据上报

'use strict';
const request = require('request-promise');
const md5 = require('md5');
const uuid = require('uuid');
const _ = require('lodash');
... ... @@ -20,6 +21,34 @@ const UserService = require('./user-service');
const LoginApi = require('./login-api');
const logger = global.yoho.logger;
class BaiduSDK {
/*
* @ description: 广告主回传转化数据接口, 上报百度
* @ author: huzhiming
* @ date: 2019-11-19 17:21:29
* @ version: v1.0.0
* 详情见文档:[http://ocpc.baidu.com/developer/d/guide/?iurl=api%2Fapi-doc%2Fapi-interface%2F]
*/
static reportOcpcApi({
token = '7GULUkX90QLZU6cHO9OEqUsRKttGNqpN@O62eFfb91OUVhmkakV1bQHIxF8xURBvP',
conversionTypes = [{ logidUrl: '', newType: null }]
}) {
request({
method: 'POST',
uri: 'http://ocpc.baidu.com/ocpcapi/api/uploadConvertData',
body: {
token,
conversionTypes
},
json: true
}).then((result) => {
console.log(`[账号注册成功后上报 百度ocpc返回信息:${JSON.stringify(result)}`);
}).catch((error) => {
console.log(`[账号注册成功后上报 百度ocpc失败 错误信息:${error}`);
});
}
}
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
... ... @@ -125,6 +154,23 @@ module.exports = class extends global.yoho.BaseModel {
domain: config.cookieDomain
});
/*
* @ description: feat(oCPC搜索推广): 推广链接转化数据发送给百度服务器,埋点:OCPC推广链接打开并完成注册进行数据上报
* @ author: huzhiming
* @ date: 2019-11-19 19:09:39
* @ version: v1.0.0
* bd_vid_path存值见:public/js/common.js 文件
*/
const logidUrl = req.cookies.bd_vid_path;
if (logidUrl) {
BaiduSDK.reportOcpcApi({
conversionTypes: {
logidUrl,
newType: 25
}
});
}
req.session.TOKEN_ = publicToken;
req.session.LOGIN_UID_ = uid;
... ...
... ... @@ -130,6 +130,17 @@ function getShoppingKey() {
if (window._yas) {
window._yas(1 * new Date(), window._yasVersion, 'yohobuy_web', uid, '', '');
}
/* 【加入ocpcApi代码】: 判断当前页面地址若百度sem推广链接,即将推广链接存到cookies,支付成功后将推广链接上报百度 ocpcapi
* @ description: 收集百度sem推广链接
* @ author: huzhiming
* @ date: 2019-11-18 16:55:17
* @ version: v1.0.0
* 详情见文档:[http://ocpc.baidu.com/developer/d/guide/?iurl=api%2Fapi-doc%2Fapi-interface%2F]
*/
if (location.href.includes('bd_vid=')) {
setCookie('bd_vid_path', location.href, { path: '/' });
}
}());
// window.resize在width<1180时适配成990
... ...