Accessing Adobe Analytics data through the API¶
Setup¶
In [ ]:
Copied!
!pip install python-dotenv
!pip install git+http://github.com/dancingcactus/python-omniture.git
!pip install python-dotenv
!pip install git+http://github.com/dancingcactus/python-omniture.git
Collecting python-dotenv Downloading https://files.pythonhosted.org/packages/32/2e/e4585559237787966aad0f8fd0fc31df1c4c9eb0e62de458c5b6cde954eb/python_dotenv-0.15.0-py2.py3-none-any.whl Installing collected packages: python-dotenv Successfully installed python-dotenv-0.15.0 Collecting git+http://github.com/dancingcactus/python-omniture.git Cloning http://github.com/dancingcactus/python-omniture.git to /tmp/pip-req-build-bbr28lis Running command git clone -q http://github.com/dancingcactus/python-omniture.git /tmp/pip-req-build-bbr28lis Requirement already satisfied: requests in /usr/local/lib/python3.6/dist-packages (from omniture==0.5.2) (2.23.0) Requirement already satisfied: python-dateutil in /usr/local/lib/python3.6/dist-packages (from omniture==0.5.2) (2.8.1) Requirement already satisfied: chardet<4,>=3.0.2 in /usr/local/lib/python3.6/dist-packages (from requests->omniture==0.5.2) (3.0.4) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/dist-packages (from requests->omniture==0.5.2) (2020.12.5) Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/local/lib/python3.6/dist-packages (from requests->omniture==0.5.2) (1.24.3) Requirement already satisfied: idna<3,>=2.5 in /usr/local/lib/python3.6/dist-packages (from requests->omniture==0.5.2) (2.10) Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/dist-packages (from python-dateutil->omniture==0.5.2) (1.15.0) Building wheels for collected packages: omniture Building wheel for omniture (setup.py) ... done Created wheel for omniture: filename=omniture-0.5.2-cp36-none-any.whl size=31364 sha256=fea65674ddfa3e0be42622f5092af1ef8ba29116af73cbf1940b232077862e30 Stored in directory: /tmp/pip-ephem-wheel-cache-kpx8t95r/wheels/60/1b/3a/ff25df48b31ec65e26c8f9acab710476161d0ba168b4c6c9be Successfully built omniture Installing collected packages: omniture Successfully installed omniture-0.5.2
In [ ]:
Copied!
# authorise use of google drive
from google.colab import drive
drive.mount('/content/drive')
# authorise use of google drive
from google.colab import drive
drive.mount('/content/drive')
In [ ]:
Copied!
import omniture # https://github.com/dancingcactus/python-omniture
import pandas as pd
import os
from dotenv import load_dotenv # https://github.com/theskumar/python-dotenv
import omniture # https://github.com/dancingcactus/python-omniture
import pandas as pd
import os
from dotenv import load_dotenv # https://github.com/theskumar/python-dotenv
In [ ]:
Copied!
load_dotenv('/content/drive/My Drive/creds/env.txt')
load_dotenv('/content/drive/My Drive/creds/env.txt')
In [ ]:
Copied!
# set variables containing cretentials
username = os.getenv("AAUSERNAME")
secret = os.getenv("AASECRET")
# set variables containing cretentials
username = os.getenv("AAUSERNAME")
secret = os.getenv("AASECRET")
In [ ]:
Copied!
# Establish connection with Adobe Analytics
analytics = omniture.authenticate(username, secret)
# Establish connection with Adobe Analytics
analytics = omniture.authenticate(username, secret)
Set up report and pull data¶
In [ ]:
Copied!
report = analytics.suites["suite_name"]\
.report\
.metric(['visits'])\
.range('2020-12-01', '2020-12-10', granularity='day')\
.run()
report = analytics.suites["suite_name"]\
.report\
.metric(['visits'])\
.range('2020-12-01', '2020-12-10', granularity='day')\
.run()
In [ ]:
Copied!
data = report.dataframe
data = report.dataframe
In [ ]:
Copied!
data
data
In [ ]:
Copied!