打算使用ADBPhoneGap插件在我的移动应用中实施Adobe Analytics。 以下是代码,我正在尝试在Link中要求执行的基本配置。 我得到的错误是无法读取Undefined的属性'ADB'。如何解决问题。也无法弄清楚上述链接中提到的实施“生命周期指标自动跟踪”的内容和位置。任何人都可以使用trackState或trackAction方法的基本脚本,参考以下示例。
<!DOCTYPE HTML>
<html>
<head>
<!-- <meta name="viewport" content="width=320; user-scalable=no" /> -->
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>PhoneGap</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title">
<script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script>
<script type="text/javascript" charset="utf-8" src="ADB_Helper.js"></script>
<script type="text/javascript">
var ADB;
function initialize() {
alert('In initalize');
document.addEventListener("deviceready", onDeviceReady, true);
//alert('Device Ready');
alert('Exit initalize');
}
function onDeviceReady() {
alert('in On Device Ready method');
ADB = window.plugins.ADB;
alert('Exit On Device Ready method'+ADB);
// Note: A request for permission is REQUIRED by google. You probably want to do this just once, though, and remember the answer for subsequent runs.
navigator.notification.confirm('GA_PLUGIN would like your permission to collect usage data. No personal or user identifiable data will be collected.', permissionCallback, 'Attention', 'Allow,Deny');
}
function TrackButtonClicked()
{
alert('Track Button Entry');
// ADB.trackState("login page", {"user":"john","remember":"true"});
alert('Track Button Exit');
}
</script>
</head>
<body onload="initialize();" id="stage" class="theme"> <!-- onunload="goingAway();" -->
<h1>Test Adobe Analytics Plugin</h1>
<div class="space"></div>
<div>
<a href="#" class="btn large" onclick="TrackButtonClicked();">Track Event</a>
<!--<a href="#" class="btn large" onclick="VariableButtonClicked();">Track Event with Variable</a>
<a href="#" class="btn large" onclick="PageButtonClicked();">Track Page</a>-->
</div>
</body>
</html>
答案 0 :(得分:1)
由于已经声明了名为 ADB 的ADBHelper.js变量,您似乎在代码中覆盖了两次。首先你用{/ 3>来shadow
var ADB
在您的全球范围内,实际上意味着覆盖它。然后你做
ADB = window.plugins.ADB;
再将其设置为 window.plugins.ADB ,它似乎是 undefined 。
所以删除这两行,之后,如果插件安装正确, ADB 应该已经是包含Adobe Analytics方法的对象。