fix ga
This commit is contained in:
parent
3a0765e11e
commit
97db30a0b9
1 changed files with 10 additions and 13 deletions
|
|
@ -7,24 +7,21 @@ function appendScript () {
|
||||||
}
|
}
|
||||||
|
|
||||||
function init (id) {
|
function init (id) {
|
||||||
let ga = window.ga
|
appendScript()
|
||||||
|
window.ga = window.ga || function () {
|
||||||
if (!ga) {
|
(window.ga.q = window.ga.q || []).push(arguments)
|
||||||
appendScript()
|
|
||||||
ga = ga || function () {
|
|
||||||
(ga.q = ga.q || []).push(arguments)
|
|
||||||
}
|
|
||||||
ga.l = Number(new Date())
|
|
||||||
ga('create', id, 'auto')
|
|
||||||
}
|
}
|
||||||
return ga
|
window.ga.l = Number(new Date())
|
||||||
|
window.ga('create', id, 'auto')
|
||||||
}
|
}
|
||||||
|
|
||||||
function collect () {
|
function collect () {
|
||||||
const ga = init($docsify.ga)
|
if (!window.ga) {
|
||||||
|
init($docsify.ga)
|
||||||
|
}
|
||||||
|
|
||||||
ga('set', 'page', location.hash)
|
window.ga('set', 'page', location.hash)
|
||||||
ga('send', 'pageview')
|
window.ga('send', 'pageview')
|
||||||
}
|
}
|
||||||
|
|
||||||
const install = function (hook) {
|
const install = function (hook) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue