Adobe Analytics API : getElements

On the Adobe Analytics API, the first method you can use from the library is the getElements.

Why this getElements method ?

When you want to start the API from Adobe Analytics, you first need to create the statement.
As seen during the post that explains the Statement class, you can almost start empty from the console and build the statement one element by another.
However the problems come rapidly that there is a need for the id of the elements to be requested in the statement.
As for the props, evars and event it can be quite easy to guess which one to use, the id is only the number of the element you want to retrieve.
Per instance, if you want to use the eVar that retrieve your website url, you can just set the id of the eVar in your statement :

The elements part of your statement will look like :

For events and props, it works exactly the same. Prop in the same place than evar, event inside the metrics place of your statement.

As you could see there are some exception to the rules (“visits”, “orders”, “revenue”, etc….) but it is globally self-explanatory and doesn’t require the API for that. Even if you are not responsible for the implementation and don’t know exactly which eVar or props has been used, you would just need to go to your “Conversion Variables”, “Success Events” or “Traffic Variables” panel to actually retrieve this information.

For the calculated metrics and the segments, however, it is quite different as there is no easy-to-remember id that are created. Especially because 2 calculated metrics or 2 segments can have the same name. So Adobe had to come with something unique for every one of them.

The element can look like this :

You can guess, you cannot make those id up. This is where the getElements function come handy.

 getElements method

This method can takes several arguments and will return, depending of your choice, a dictionary of pandas dataframes with the different elements you requested or save the different elements you requested in a csv file, each element requested will be one file, or this function return both.

Possible arguments to pass :

  • evars
  • events
  • props
  • calcmetrics
  • segments

Those arguments are the elements that you can request from this method. You don’t have to request all of them, you can just request one.
The return_data keyword argument, when set to True, will return you the dictionary with the dataframe attached to their respective arguments.
The export keyword argument, when set to True, will write csv export for each of the requested elements.
The response, on this example will look like :

df_all = {
“evars” : <dataframe_evar>,
“props” : <dataframe_props>,
“events” : <dataframe_events>,
“calcmetrics” : <dataframe_calcmetrics>,
“segments” : <dataframe_segments>

In case of doubt, you can always use the help function on the console to see the details.

On this series, you may want to read as well :

2 thoughts on “Adobe Analytics API : getElements

  1. Hi I’m running into this error trying to use the 1.4 and 2.0 versions.
    SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)
    Do you know why this could be happening?

Leave a Reply

Your email address will not be published. Required fields are marked *