有人可以帮帮我..?
GA中没有捕获数据。我使用GTM for Android(最新版本),我已经做了以下事情:
这是目前使用的大部分代码:
public class SplashActivity extends AppCompatActivity {
private static final long TIMEOUT_FOR_CONTAINER_OPEN_MILLISECONDS = 2000;
private static final String CONTAINER_ID = "GTM-XXXXXX";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TagManager tagManager = TagManager.getInstance(this);
if (Environment.get() != BaseEnvironment.PRODUCTION) {
tagManager.setVerboseLoggingEnabled(true);
}
PendingResult<ContainerHolder> pending = tagManager.loadContainerPreferNonDefault(CONTAINER_ID, R.raw.gtm_xxxxxx);
pending.setResultCallback(new ResultCallback<ContainerHolder>() {
@Override
public void onResult(ContainerHolder containerHolder) {
ContainerHolderSingleton.setContainerHolder(containerHolder);
if (! containerHolder.getStatus().isSuccess()) {
return;
}
Intent intent = new Intent(SplashActivity.this, NavigationActivity.class);
startActivity(intent);
}
}, TIMEOUT_FOR_CONTAINER_OPEN_MILLISECONDS, TimeUnit.MILLISECONDS);
}
}
@Override
public void onStart() {
super.onStart();
TagUtils.pushOpenScreenEvent(this, "Informatie");
}
@Override
protected void onStop() {
super.onStop();
TagUtils.pushCloseScreenEvent(this, "Informatie");
}
/**
* Push an "openScreen" event with the given screen name. Tags that match that event will fire.
*/
public static void pushOpenScreenEvent(Context context, String screenName) {
DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
dataLayer.pushEvent("openScreen", DataLayer.mapOf(
"screenName", screenName,
"appVersion", appVersionName(context),
"operatingSystem", systemVersion()
));
}
/**
* Push a "closeScreen" event with the given screen name. Tags that match that event will fire.
*/
public static void pushCloseScreenEvent(Context context, String screenName) {
DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
dataLayer.pushEvent("closeScreen", DataLayer.mapOf(
"screenName", screenName,
"appVersion", appVersionName(context),
"operatingSystem", systemVersion()
));
}
/**
* Push a "scanProduct" event with the given screen name. Tags that match that event will fire.
*/
public static final String ACTION_PRODUCT_FOUND = "Product gevonden";
public static final String ACTION_PRODUCT_NOT_FOUND = "Product niet gevonden";
public static final String ACTION_PRODUCT_NOT_FOUND_CONNECTION_ISSUES = "Product niet opgehaald door verbindingsproblemen";
public static void pushScanProductEvent(Context context, String action, String code) {
DataLayer dataLayer = TagManager.getInstance(context).getDataLayer();
dataLayer.pushEvent("scanProduct", DataLayer.mapOf(
"Category", "Scan",
"Action", action,
"Label", code
));
}
<activity
android:name="com.google.android.gms.tagmanager.PreviewActivity"
android:label="@string/app_name"
android:noHistory="true">
<intent-filter>
<data android:scheme="tagmanager.c.nl.everybodylikespenguins" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
请注意我隐藏了容器文件ID和数据android:scheme =&#34; tagmanager.c.nl.everybodylikespenguins&#34; 确实是接受构建的正确名称应用程序(Google也在其示例中使用此功能)。
答案 0 :(得分:0)
看起来你没有在onResult回调中调用containerHolder.getContainer()。激活容器需要调用getContainer。