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 :
"elements":[ {"id":"evarXX"}],
For events and props, it works exactly the same. Prop in the same place than evar, event inside the metrics place of your statement.
"metrics":[ {"id":"visits"} {"id" : "eventXX"}, ],
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 :
"segments":[ {"id":"s919_58a41f04e4b06f485693f59a"}]
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 :
df_all = aanalytics.getElements('evars','events','props','calcmetrics','segments',return_data=True,export=True)
- 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.
help(aanalytics.getElements)
On this series, you may want to read as well :
Article | Content |
Introduction | What is to know about the Adobe Analytics API with Python |
Requirements | What is necessary to know and to be done before you start with the aanalytics module |
Statement creation | What is a statement and why is it import for the API |
Statement Class | What is a the statement Class and how can it help you created a statement |
Getelements method | Explanation on how the getElements method works |
Getelements method | Explanation on how the getReport method works |
Getelements method | Explanation on how the retrieveReport method works |
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?
Just a link that may give you a solution: https://stackoverflow.com/questions/51390968/python-ssl-certificate-verify-error