当前位置: 首页 > news >正文

怎么到百度做网站搜索引擎推广和优化方案

怎么到百度做网站,搜索引擎推广和优化方案,福永网站设计,响应式网站开发一、统计app激活状态 在App.vue 中 利用onShow生命周期验证 或者操作 onShow: function () { uni.showToast({ title: onShow }) }, 二、页面级别的统计 (进入页面、停留时长、手机系统信息、网络状态、页面路径、标题) 需要收集的数据 { &quo…

一、统计app激活状态

在App.vue 中 利用onShow生命周期验证 或者操作

onShow: function () {

uni.showToast({

title: 'onShow'

})

},

二、页面级别的统计 (进入页面、停留时长、手机系统信息、网络状态、页面路径、标题)

需要收集的数据

{

"pageType": "leavePage",

"networkType": "wifi",

"pageInfo": {

"pageUrl": "pages/index/newIndex",

"title": ""

},

"entryTime": "2024-04-10 13:18:50",

"leaveTime": "2024-04-10 13:18:51",

"nowTime": "2024-04-10 13:18:51",

"stayTime": 279,

"sysTemInfo": {

"appName": "某某app",

"appVersion": "2.1.4",

"brand": "apple",

"platform": "ios",

"system": "iOS 17.3.1"

},

"pageLoadTime": 873

}

通过混入mixins 每个页面生命周期埋点统计、编写逻辑方法

三、页面内部事件级别的统计 (各种事件信息集合eventTrack(点击、复制、下载、来源某个特定页面的操作)、 手机系统信息、网络状态、页面路径、标题)

需要收集的数据

{

"networkType": "unknown",

"pageInfo": {

"pageUrl": "pages/order/index",

"title": "订单"

},

"sysTemInfo": {

"appName": "某某app",

"appVersion": "2.1.4",

"brand": "xiaomi",

"platform": "android",

"system": "Android 12"

},

"eventTrack": { // 事件所需要的埋点字段

"eventCode": "B0004"

}

}

通过混入mixins 每个页面生命周期埋点统计、编写逻辑方法

四、具体的设计流程

1、创建 埋点sdk方法 pointCom.js

主要三个方法

myPointPage, 页面级别触发的

toDateDetail, 时间转化函数

myPointEvent, 页面内部事件触发的

详细编码

import { pagesObj } from '@/uni-config/pages.js' // 页面路由和标题的映射map

console.log(pagesObj, 'uni-config')

async function myPointPage(pageType = "", pageUrl = "") {

console.log("埋点", pageType, pageUrl);

let entryTime, leaveTime, stayTime, nowTime;

if (!pageType) return;

if (pageType == "entryPage") {

entryTime = new Date().getTime();

nowTime = new Date().getTime();

leaveTime = null;

uni.setStorageSync("entryTime", entryTime);

} else {

entryTime = uni.getStorageSync("entryTime");

leaveTime = new Date().getTime();

stayTime = leaveTime - entryTime;

nowTime = new Date().getTime();

}

uni.getNetworkType({

success: function (res) {

let networkType = res.networkType;

try {

uni.getSystemInfo({

success: function (res) {

let { appName,

appWgtVersion,

brand,

platform,

system } = res

let data = {

pageType: pageType,

networkType: networkType,

pageInfo: {

pageUrl: pageUrl,

title: pagesObj[pageUrl]

},

entryTime: toDateDetail(entryTime),

leaveTime: toDateDetail(leaveTime),

nowTime: toDateDetail(nowTime),

stayTime: stayTime,

sysTemInfo: {

appName,

appVersion: appWgtVersion,

brand,

platform,

system

},

};

if (pageType === "leavePage") {

data.pageLoadTime = uni.getStorageSync("pageLoadTime");

}

console.log('发送调用埋点接口', data)

},

fail(error) {

sysTemInfo = "null";

},

});

} catch (e) { }

},

});

}

async function myPointEvent(eventTrack = {}, pageUrl = "") {

uni.getNetworkType({

success: function (res) {

let networkType = res.networkType;

try {

uni.getSystemInfo({

success: function (res) {

let { appName,

appWgtVersion,

brand,

platform,

system } = res

let data = {

networkType: networkType,

pageInfo: {

pageUrl: pageUrl,

title: pagesObj[pageUrl]

},

sysTemInfo: {

appName,

appVersion: appWgtVersion,

brand,

platform,

system

},

eventTrack

};

console.log('myPointEvent发送调用埋点接口', data)

},

fail(error) {

sysTemInfo = "null";

},

});

} catch (e) { }

},

});

}

function toDateDetail(number) {

if (!number) return undefined;

// var n = number * 1000

var date = new Date(number);

var Y = date.getFullYear() + "-";

var M =

(date.getMonth() + 1 < 10

? "0" + (date.getMonth() + 1)

: date.getMonth() + 1) + "-";

var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();

var h = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();

var mm = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();

var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

return Y + "" + M + "" + D + " " + h + ":" + mm + ":" + s;

}

export default {

myPointPage,

toDateDetail,

myPointEvent,

};

2、创建 埋点混入的方法和生命周期 pointMixin.js

主要四个方法

eventTrack, 页面事件调用的函数

entryTrack, 页面进入调用的函数

leaveTrack, 页面离开调用的函数

pageLoadTime 页面onReady调用的函数

详细编码

import pointCom from "@/utils/pointCom.js";

export default {

data() {

return {

pointPageUrl: "", //跳转url

pageType: "", //事件类型 进入、离开

loadStartTime: "", //页面加载开始时间

};

},

onLoad() {

this.entryTrack();

},

onReady() {

this.pageLoadTime();

},

onHide() {

this.leaveTrack();

},

onUnload() {

this.leaveTrack();

},

methods: {

eventTrack(eventTrack = {}) {

console.log('eventTrack', eventTrack, this.pointPageUrl)

let pointPageUrl = getCurrentPages()[getCurrentPages().length - 1].route;

this.pointPageUrl = pointPageUrl;

pointCom.myPointEvent(eventTrack, this.pointPageUrl);

},

entryTrack() {

let loadStartTime = pointCom.toDateDetail(Number(new Date()));

let pointPageUrl = getCurrentPages()[getCurrentPages().length - 1].route;

this.pointPageUrl = pointPageUrl;

this.pageType = "entryPage";

this.loadStartTime = loadStartTime;

pointCom.myPointPage("entryPage", this.pointPageUrl);

},

pageLoadTime() {

let pageLoadTime = Number(new Date()) - new Date(this.loadStartTime).getTime()

console.log("pageLoadTime", pageLoadTime, this.loadStartTime)

uni.setStorageSync("pageLoadTime", pageLoadTime);

},

leaveTrack() {

if (this.pageType === "leavePage") return;

this.pageType = "leavePage";

pointCom.myPointPage("leavePage", this.pointPageUrl);

},

},

};

3、main.js 引入 pointMixin.js

详细编码

import pointMixin from "@/utils/pointMixin"; //配合埋点的mixin

Vue.mixin(pointMixin);

4、得到页面路由和标题的映射map

h5中可以得到标题等数据,但是app中无法获取

// 获取当前页面链接和参数

function getCurrentPageUrlWithArgs() {

const pages = getCurrentPages();

const currentPage = pages[pages.length - 1];

const route = currentPage?.route;

const options = currentPage?.options || {};

const title = currentPage?.$holder?.navigationBarTitleText || ''

console.log(title)

let urlWithArgs = /${route}?;

for (let key in options) {

const value = options[key];

urlWithArgs += ${key}=${value}&;

}

urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1);

return {

options, //当前页面的参数

urlWithArgs, //当前页面的参数

route,

title,

};

}

app获取相关数据需要另辟蹊径

通过文件的读取和写入来实现
具体编码

const fs = require("fs-extra")

let path = require("path")

let Hjson = require("hjson")

const chokidar = require("chokidar")

let rootPath = (function () {

let e = path.resolve(__dirname, "./")

return e

})()

function creatPagesJs() {

try {

const fileContent = fs.readFileSync('./pages.json', 'utf8');

const jsonObj = Hjson.rt.parse(fileContent);

let pages = jsonObj.pages

let pagesObj = {}

pages.map(item => {

let path = item.path

let title = item?.style?.navigationBarTitleText || ''

pagesObj[path] = title

})

console.log(pagesObj, 'pagesObj')

let pstr = "export const pagesObj = " + JSON.stringify(pagesObj, null, 2);

fs.outputFileSync(

path.resolve(rootPath, "uni-config", "pages.js"),

pstr

);

} catch (err) {

console.log(err);

}

}

const watcherPagesJson = chokidar

.watch(path.resolve(__dirname, "./pages.json"))

watcherPagesJson.on("all", (event, path) => {

console.log(event, path, 'pages.json')

if (event == "change") {

creatPagesJs()

}

})

creatPagesJs();

如何调用 package.json 配置调用命令

"scripts": {

"getPages": "node getPages.js"

},


文章转载自:
http://yellowfin.sqxr.cn
http://objectively.sqxr.cn
http://roose.sqxr.cn
http://baathist.sqxr.cn
http://neodoxy.sqxr.cn
http://backbite.sqxr.cn
http://mesogloea.sqxr.cn
http://prelatise.sqxr.cn
http://anemochorous.sqxr.cn
http://exigent.sqxr.cn
http://rainmaker.sqxr.cn
http://giblets.sqxr.cn
http://rucksackful.sqxr.cn
http://scordato.sqxr.cn
http://reconvict.sqxr.cn
http://facty.sqxr.cn
http://nannoplankton.sqxr.cn
http://cuirassier.sqxr.cn
http://sexivalent.sqxr.cn
http://gravel.sqxr.cn
http://thoroughly.sqxr.cn
http://behaviouristic.sqxr.cn
http://sanitarily.sqxr.cn
http://ogival.sqxr.cn
http://portia.sqxr.cn
http://chicken.sqxr.cn
http://hydroscope.sqxr.cn
http://elision.sqxr.cn
http://geopressured.sqxr.cn
http://narcomatous.sqxr.cn
http://underpan.sqxr.cn
http://actinomycotic.sqxr.cn
http://weary.sqxr.cn
http://perlustrate.sqxr.cn
http://pah.sqxr.cn
http://thrashing.sqxr.cn
http://vendable.sqxr.cn
http://gypsum.sqxr.cn
http://atrociously.sqxr.cn
http://semimystical.sqxr.cn
http://mdr.sqxr.cn
http://retch.sqxr.cn
http://dns.sqxr.cn
http://periodic.sqxr.cn
http://kiev.sqxr.cn
http://malodor.sqxr.cn
http://revisability.sqxr.cn
http://laugher.sqxr.cn
http://frowardly.sqxr.cn
http://indigence.sqxr.cn
http://polyphony.sqxr.cn
http://ritually.sqxr.cn
http://dissenting.sqxr.cn
http://dolman.sqxr.cn
http://legerity.sqxr.cn
http://scaled.sqxr.cn
http://disproportional.sqxr.cn
http://asparaginase.sqxr.cn
http://thermophosphorescence.sqxr.cn
http://ultrafiltrate.sqxr.cn
http://foreboding.sqxr.cn
http://esthonia.sqxr.cn
http://draftiness.sqxr.cn
http://upshot.sqxr.cn
http://goldeye.sqxr.cn
http://affirmant.sqxr.cn
http://latona.sqxr.cn
http://repletion.sqxr.cn
http://oxygenous.sqxr.cn
http://flattering.sqxr.cn
http://stairway.sqxr.cn
http://contrariwise.sqxr.cn
http://nebulizer.sqxr.cn
http://lassallean.sqxr.cn
http://quatercentennial.sqxr.cn
http://germproof.sqxr.cn
http://wicket.sqxr.cn
http://impurely.sqxr.cn
http://magnetosheath.sqxr.cn
http://outmaneuvre.sqxr.cn
http://lcj.sqxr.cn
http://comdex.sqxr.cn
http://tittlebat.sqxr.cn
http://truckway.sqxr.cn
http://horticultural.sqxr.cn
http://trapt.sqxr.cn
http://bestrow.sqxr.cn
http://anelectric.sqxr.cn
http://samdwich.sqxr.cn
http://pohai.sqxr.cn
http://pang.sqxr.cn
http://ironhearted.sqxr.cn
http://rushwork.sqxr.cn
http://compartmentation.sqxr.cn
http://morwong.sqxr.cn
http://confirm.sqxr.cn
http://denticare.sqxr.cn
http://etude.sqxr.cn
http://under.sqxr.cn
http://plantation.sqxr.cn
http://www.15wanjia.com/news/90472.html

相关文章:

  • 选择ssm框架做网站的好处市场调研的五个步骤
  • 外贸网站假设永州网站seo
  • 蔡甸建设局网站石家庄最新疫情最新消息
  • 做产地证需要备案上哪个网站nba最新消息交易情况
  • 我的世界做神器指令网站网站宣传方法
  • dedecms蓝色企业网站模板免费下载郑州网站推广优化
  • 织梦网站漏洞修复长尾关键词挖掘熊猫
  • 网站的类型及特点口碑好的设计培训机构
  • 东营做网站tt0546写文的免费软件
  • 动漫人物做羞羞事的网站工具站seo
  • 惠州建设网站开发百度售后电话人工服务
  • 深圳做网站哪个好网站推广文章
  • 教育网站制作品牌营销策略论文
  • jquery网站模板营销型网站建设解决方案
  • 专门做网站的公司叫什么如何免费注册一个网站
  • 网站备案注销怎么推广销售
  • 宜昌有做网站的公司吗论坛外链代发
  • joomla适合做什么网站营销课程培训
  • 佛山网站建设报价关键词怎么选择技巧
  • 上海南京东路网站建设深圳网络推广哪家
  • 网站空白栏目监管百度极速版客服人工在线咨询
  • 交友网站如果建设在线咨询 1 网站宣传
  • 020网站建设营销型网站建设步骤
  • 网站建设 军报推广计划怎么做推广是什么
  • 做网站独立云服务器什么意思站长之家ping
  • 怎样建立自己购物网站外链生成器
  • 微网站开发不用模板营销策划案的模板
  • 网站建设 岗位职责成都网站建设软件
  • SUPERW上海网站建设工作室赣州网站建设
  • 兼职做效果图的网站快抖霸屏乐云seo