Pull a dynamic report suite id from data layer

jonas_franklin

15-10-2015

Hi,

I would like to pull the report suite id's dynamically from the page. I have stored the report suite id in a JSON data layer.

It seems that the report suit ID can be set as a static variable or automatically be pulled from the tool Account ID field. I would like to be able to pull the report suite id via either a data element directly in the account ID field %dl_reportsuiteid% or in the s_code.

I have managed to get this to work by giving the tool account ID a static value which i then verify with an if statement in the s_code file like this:

function getAnalyticsAccount() {
    for(var toolid in _satellite.tools) {
        if(_satellite.tools[toolid].settings.engine == "sc") {
            return _satellite.tools[toolid].settings.account;
        }
    }
}

if(s.account = "Staging") {
  s.account = _satellite.getVar("DL_Binfo-reportSuiteListStaging");
}
else if (s.account = "Production") {
  s.account = _satellite.getVar("DL_reportSuiteListProd");
}

This works on a page load event but when i fire an event based rule, the report suite id seems to be pulled from the tool account ID which in this case is "Staging" or "Production".

Have anyone solved this, by pulling a report suite list from a data layer?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

adam_haining

15-10-2015

Hi Jonas,

With the latest release of Adobe Analytics, you can now use a custom report suite ID by checking the box under "Library Management" labeled as "Set report suites using custom code below".  This will allow you to set the report suite ID under the global s_account variable, and DTM will use that.  This means that you can set it based on the data elements you've setup for each environment.  Here is some updated code I recommend be used.

function getAnalyticsAccount() {
    for(var toolid in _satellite.tools) {
        if(_satellite.tools[toolid].settings){
            if(_satellite.tools[toolid].settings.engine == "sc") {
                return _satellite.tools[toolid].settings.account;
            }
        }
    }
}
var s_account = getAnalyticsAccount()=="Staging" ? _satellite.getVar("DL_Binfo-reportSuiteListStaging") : _satellite.getVar("DL_reportSuiteListProd");
var s = s_gi(s_account);

This will set the s_account variable based on the data element, and will also create the s object with the report suite ID that has been set, which is actually really important.  Once this is all in place, it should all work as expected.