Hi,
I have set up my Google Tag Manager and Google Analytics and linked them with one another. Then, I have set up a container in Google Tag Manager and added a variable called "Google Analytics Content Experiment" within the container. I created 2 types of experiment variations ( you can refer the picture).I have also set "Percentage of Users Included in Experiment" to be 50%, so that 50% users get the default config value from the json and the other 50% users get the different value.Then, I published by container and downloaded the binary file and included it in the "raw" folder of the android app.
Then in my android app, I did the following within the onCreate method:
TagManager tagManager = TagManager.getInstance(this);
// Modify the log level of the logger to print out not only
// warning and error messages, but also verbose, debug, info messages.
tagManager.setVerboseLoggingEnabled(true);
PendingResult<ContainerHolder> pending =
tagManager.loadContainerPreferNonDefault(CONTAINER_ID,
R.raw.gtm_default_container);
pending.setResultCallback(new ResultCallback<ContainerHolder>() {
@Override
public void onResult(ContainerHolder containerHolder) {
ContainerHolderSingleton.setContainerHolder(containerHolder);
Container container = containerHolder.getContainer();
if (!containerHolder.getStatus().isSuccess()) {
Log.e("CuteAnimals", "failure loading container");
//displayErrorToUser(R.string.load_error);
return;
}
}
}, 2, TimeUnit.SECONDS);
My objective is to get the values of the key "key1" as supplied by the google tag manager in the android app, so that I can drive the application accordingly. But, I cannot get the values.
Can someone kindly help me out ?
Thanks.
Ones container is loaded successfully, You should be able to load the Experiment variations data.
For Example in your case this would be containerHolder.getContainer().getString("key1")
Based on your content Experiment variations rate you will get the values "blue", "green" on different devices..