我正在测试Optimizely并在我的reactjs项目中创建了一个实现。优化脚本仅在需要时加载(lazyLoad),因此,在仪表板中创建新实验时,我得到“页面中不存在的片段”错误,可以忽略。
通过应用程序运行实验时,我可以访问活动变体等。日志不会显示或显示任何错误。
当前的实施或测试是在我们的私人服务器上进行的,不确定它是否与问题有关;所以除非你连接到VPN,否则你无法看到该页面。
目前,只有我必须访问它,但我应该在报告中看到一些流量,但到目前为止已经为0。
日志中没有任何错误
4678891099.js:212 Optimizely / Main / Started, revision 99 [time 0 +0]
4678891099.js:212 Optimizely / Query / Blocked request to load unsafe script: null [time 9 +9]
4678891099.js:212 Optimizely / Segmenter / Loading segments cookie. [time 13 +4]
4678891099.js:212 Optimizely / Segmenter / Segments cookie contains segment id: 4680143815 [time 13 +0]
4678891099.js:212 Optimizely / Segmenter / Segments cookie contains segment id: 4650727160 [time 13 +0]
4678891099.js:212 Optimizely / Segmenter / Segments cookie contains segment id: 4679173736 [time 13 +0]
4678891099.js:212 Optimizely / Activator / Triaging 3 segments. [time 13 +0]
4678891099.js:212 Optimizely / Condition / Testing segment 4680143815 [time 14 +1]
4678891099.js:212 Optimizely / Activator / Passed conditions for segment 4680143815 [time 14 +0]
4678891099.js:212 Optimizely / Condition / Testing segment 4650727160 [time 14 +0]
4678891099.js:212 Optimizely / Activator / Passed conditions for segment 4650727160 [time 14 +0]
4678891099.js:212 Optimizely / Condition / Testing segment 4679173736 [time 14 +0]
4678891099.js:212 Optimizely / Activator / Passed conditions for segment 4679173736 [time 14 +0]
4678891099.js:212 Optimizely / Segmenter / Evaluating Segment 4680143815 [time 14 +0]
4678891099.js:212 Optimizely / Segmenter / Evaluating Segment 4650727160 [time 14 +0]
4678891099.js:212 Optimizely / Segmenter / Evaluating Segment 4679173736 [time 14 +0]
4678891099.js:212 Optimizely / Integrator / Loading third-party segments. [time 18 +4]
4678891099.js:212 Optimizely / Visitor / Initializing [time 18 +0]
4678891099.js:212 Optimizely / Visitor / Found segment 4680143815 [time 19 +1]
4678891099.js:212 Optimizely / Visitor / Found segment 4650727160 [time 19 +0]
4678891099.js:212 Optimizely / Visitor / Found segment 4679173736 [time 19 +0]
4678891099.js:212 Optimizely / Info / Is Classic Optimizely enabled: true [time 20 +1]
4678891099.js:212 Optimizely / Info / Diagnostic enabled: false [time 20 +0]
4678891099.js:212 Optimizely / Info / Force variation enabled: false [time 20 +0]
4678891099.js:212 Optimizely / Info / Browser type: gc [time 20 +0]
4678891099.js:212 Optimizely / Info / Browser version: 61.0.3163.100 [time 20 +0]
4678891099.js:212 Optimizely / Info / Mobile browser type: android [time 20 +0]
4678891099.js:212 Optimizely / Info / New vs returning: returning [time 20 +0]
4678891099.js:212 Optimizely / Info / Source type: null [time 21 +1]
4678891099.js:212 Optimizely / Info / User ID: oeu1507206204323r0.4361859226305451 [time 22 +1]
4678891099.js:212 Optimizely / Condition / Testing experiment 8931711070 [time 22 +0]
4678891099.js:212 Optimizely / Condition / Testing URLs for experiment 8931711070 [time 22 +0]
4678891099.js:212 Optimizely / Condition / Failed to match any URL for experiment 8931711070 [time 24 +2]
4678891099.js:212 Optimizely / Condition / Testing experiment 8785608124 [time 24 +0]
4678891099.js:212 Optimizely / Condition / Testing URLs for experiment 8785608124 [time 24 +0]
4678891099.js:212 Optimizely / Distributor / Going to distribute experiment "Question variation for "Is investing for you?"" (8785608124) [time 24 +0]
4678891099.js:212 Optimizely / Distributor / Not distributing experiment 8785608124 (already in plan) [time 24 +0]
4678891099.js:212 Optimizely / Tracker / Queued tracking event 'https://foobarbeta.xyz/msl-1353-optimizely-screener-q2/risk/suitability' [time 29 +5]
4678891099.js:212 Optimizely / Tracker / Making a log request. [time 32 +3]
4678891099.js:212 Optimizely / Evaluator / 0 times waited [time 36 +4]
4678891099.js:212 Optimizely / Evaluator / 0 total times waited [time 36 +0]
4678891099.js:212 Optimizely / API / Finalizing API. [time 36 +0]
4678891099.js:212 Optimizely / Main / End of main [time 38 +2]
4678891099.js:212 Optimizely / API / Error for unknown function "page" [time 42 +4]
4678891099.js:212 Optimizely / Tracker / Removed a pending log event from the pending events cookie. [time 393 +351]
4678891099.js:212 Optimizely / Activator / Timeout: will not act on future async info. [time 2041 +1648]
4678891099.js:212 Optimizely / API / Called function "log" [time 3235 +1194]
你可以看到活跃的变体等
和报告
您还可以在下面看到customEvent或目标:
react js组件:
import React, { PropTypes } from 'react'
class OptimizelyExperiment extends React.Component {
constructor (props) {
super(props)
window.optimizely = window.optimizely || []
this.onReadyRecallMs = 10
this.defaultState = {
variantName: null,
result: null,
}
this.state = Object.assign({}, this.defaultState)
this.mapVariantToState = this.mapVariantToState.bind(this)
}
componentWillMount () {
if (!this.isReady()) {
this.insertScript()
this.observeReady(this.mapVariantToState)
}
}
componentDidMount () {
if (this.isReady()) {
this.mapVariantToState()
}
}
componentDidUpdate (prevProps, prevState) {
if (this.isReady() && prevState.variantName !== this.state.variantName) {
this.setResult()
}
}
observeReady (cb) {
const { allExperiments } = window.optimizely
if (allExperiments && typeof allExperiments[this.props.experimentId] !== 'undefined') {
this.triggerPageActivation()
this.props.customEvents.forEach(({selector, eventType, eventName}) =>
this.attachEventHandler(selector, eventType, eventName))
if (typeof cb === 'function') cb()
} else {
const t = setTimeout(() => {
clearTimeout(t)
this.observeReady(cb)
}, this.onReadyRecallMs)
}
}
mapVariantToState () {
const { activeExperiments, variationIdsMap, allVariations } = window.optimizely
activeExperiments.forEach(experimentId => {
const variationId = variationIdsMap[experimentId][0] // simple AB test, not multiple
const { name } = allVariations[variationId]
this.setState({ variantName: name })
})
}
insertScript () {
const { projectId } = this.props
const protocol = `${document.location.protocol}//`
const scriptTag = document.createElement('script')
scriptTag.type = 'text/javascript'
scriptTag.async = true
scriptTag.src = `${protocol}cdn.optimizely.com/js/${projectId}.js`
document.getElementsByTagName('head')[0].appendChild(scriptTag)
}
runExperiment () {
const { variantName } = this.state
const { experimentsMap } = this.props
let result = experimentsMap[variantName] || false
if (typeof result === 'function') {
result = result()
}
return result
}
isReady () {
return typeof window.optimizely === 'object' &&
typeof window.optimizely.data === 'object' &&
typeof window.optimizely.allExperiments === 'object'
}
setResult () {
this.setState({
result: this.runExperiment(),
})
}
triggerPageActivation () {
window.optimizely.push({
type: 'page',
pageName: this.props.pageName,
})
}
attachEventHandler (selector, eventType, eventName) {
const target = document.querySelector(selector)
const handler = () => {
window.optimizely.push({
type: 'event',
eventName: eventName,
})
target.removeEventListener(eventType, handler)
}
target.addEventListener(eventType, handler)
}
render () {
return this.state.result
}
}
OptimizelyExperiment.propTypes = {
projectId: PropTypes.string.isRequired,
experimentId: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
experimentsMap: PropTypes.object.isRequired,
pageName: PropTypes.string,
customEvents: PropTypes.array,
}
export default OptimizelyExperiment
现在,我决定更改URL Target(强制失败)并与之前的结果进行比较(在控制台日志中没有失败)。结果如下:
Optimizely / Condition / Failed to match any URL for experiment 8785608124 [time 15 +0]
所以,除非问题与VPN有关或者记者需要很长时间才能获得任何类型的数据,我不知道问题出在哪里。
答案 0 :(得分:0)
创建了一个新的实验,带有新的目标等。保留默认的“参与”目标,我之前删除了这个目标,现在我可以看到访问者和从应用程序触发的CustomEvent目标。
“参与度/点击实验页面任何部分的访问者百分比。”
这似乎是它无法正常工作的原因。