In [41]:
%matplotlib inline 

import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import pandas as pd

pd.set_option('display.width', 500)
pd.set_option('display.max_columns', 100)
pd.set_option('display.notebook_repr_html', True)
import seaborn as sns #sets up styles and gives us more plotting options

In [42]:
# Time period 1st Jan - 30th April (arbitrary )

# API credentials
# Email address 705762800217-compute@developer.gserviceaccount.com
# Key IDs 948ee8e2a420ef14a5d5a29bd35104fe2f1e6ed4

In [43]:
# open file. It is requested via API explorer using request parameters:

#Account: TMRW Tech Hub
#Property: TMRW
#View: All Web Site Data
#ids: ga:123303369
#start-date: 2017-01-01
#end-date: 2017-04-30

#metrics
#ga:sessions

#dimensions
#ga:eventAction

In [44]:
# Open file
events= pd.read_csv('files/TMRW_events.csv')

# rename columns
events.columns=['Events','Sessions'] 

# group by events
events = events.set_index('Events')

events


Out[44]:
Sessions
Events
Click 6
Form 154

In [45]:
#count rows

df=pd.DataFrame(events)
total_rows=len(df.axes[0])
print(total_rows)


2

In [49]:
#checking the count of tags

if total_rows < 5:
    result = print("Set tags to enable more user analytics features.")
    
else:
    result = True
    
result


Set tags to enable more user analytics features.

In [ ]: