Forráskód Böngészése

Merge branch 'master' into xudh

zhejiushizhuce 2 éve
szülő
commit
f22d9e047b

+ 5 - 0
src/features/actions/hallClient.js

@@ -24,6 +24,11 @@ const roger=(message,dispatch)=>{
             case "pay_finish": {
                 //充值完成 message={cmd:...,data:{Golds:12.xx,PayNum:10}}
                 handlePayFinish(message, dispatch)
+                //顺带处理打点
+                let {data}=message;
+                if(!!data&&!!data.event){
+                    trackEvent("pay",data.params);
+                }
                 break;
             }
             case "call_client":{

+ 7 - 4
src/features/mainSlice.js

@@ -1,4 +1,4 @@
-import { fb_setPixelID } from "../tracking/FacebookPixel"
+import { initTrackAll ,trackEvent} from "../tracking/TrackAll"
 import {createAsyncThunk, createSlice} from "@reduxjs/toolkit";
 import {routes} from "@db/routes";
 import {
@@ -157,9 +157,8 @@ const reducerRoutes=(state,action)=>{
             global.pf=conf.pf;
             //平台配置
             if(!!conf.pf&&!!conf.pf.id){
-                if(conf.pf.type==="fb"){
-                    fb_setPixelID(conf.pf.id);
-                }
+                let {type,id}=conf.pf;
+                initTrackAll(type,id)
             }
         }
         Object.assign(state, {routes:state.routes,asyncRoutes:data,styles:styles,blocks:blocks,...generData,isLogin:isLogin,userInfo:userInfo,hallServerUrl:hallServerUrl});
@@ -201,6 +200,10 @@ const parseLogin=(state,action,arg,isShowMsg=true)=>{
         if(isShowMsg)toast.success(msg);
         //请求pay
         // global.dispatch(reqPayConfig(data));
+        if(!!data.reg){
+            //新注册的
+            trackEvent("CompleteRegistration",{external_id:data.UserID})
+        }
     }
     else
     {

+ 34 - 2
src/tracking/TrackAll.js

@@ -1,5 +1,10 @@
-import {fb_trackEvent,fb_trackPageView} from "./FacebookPixel";
+import {fb_trackEvent,fb_trackPageView,fb_setPixelID} from "./FacebookPixel";
 
+export const initTrackAll = (pf_type,pf_id) => {
+    if(pf_type==="fb"){
+        fb_setPixelID(pf_id)
+    }
+}
 
 export const trackPageView = () => {
     if (window.fbq&&global.pf&&global.pf.type==='fb') {
@@ -9,6 +14,33 @@ export const trackPageView = () => {
 
 export const trackEvent = (eventName, params) => {
     if (window.fbq&&global.pf&&global.pf.type==='fb') {
-        fb_trackEvent(eventName, params);
+        if(eventName==="pay"){
+            let data=params;
+            if(data.first) {
+                if (!!data.isd0) {
+                    fb_trackEvent("firstpayD0", {external_id: data.udid})
+
+                    fb_trackEvent('AddToWishlist', {
+                        value: data.golds,
+                        currency: 'BRL',
+                        external_id: data.udid
+                    });
+                }
+                fb_trackEvent("firstpayD1", {external_id: data.udid})
+                fb_trackEvent('AddToCart', {
+                    value: data.golds,
+                    currency: 'BRL',
+                    external_id: data.udid
+                });
+            }
+
+            fb_trackEvent('Purchase', {
+                value: data.golds,
+                currency: 'BRL',
+                external_id:data.udid
+            });
+        }else{
+            fb_trackEvent(eventName, params);
+        }
     }
 };