def get_linger_data(self, team, slug=None, start_date=None): params = self.get_query_params(team=team, slug=slug, start_date=start_date) data = GoogleAnalytics.query_ga(params) if not data.get("rows"): logger.info("No rows found, done.") return False rows = self.clean_data(data) return rows
def get_unique_visitor_data(self, team, slug): params = self.get_query_params(team=team, slug=slug) data = GoogleAnalytics.query_ga(params) # import pdb; pdb.set_trace(); if not data.get("rows"): logger.info("No rows found, done.") return False return data.get("rows")[0][0]
def get_unique_visitor_data(self, team, slug): params = self.get_query_params(team=team, slug=slug) data = GoogleAnalytics.query_ga(params) # import pdb; pdb.set_trace(); if not data.get('rows'): logger.info('No rows found, done.') return False return data.get('rows')[0][0]
def get_linger_data(self, team, slug=None, start_date=None): params = self.get_query_params(team=team, slug=slug, start_date=start_date) data = GoogleAnalytics.query_ga(params) if not data.get('rows'): logger.info('No rows found, done.') return False rows = self.clean_data(data) return rows
def get_user_data(self, team, start_date=None): """ Get the number of users in the last seven days """ if not start_date: start_date = '90daysAgo' params = { 'ids': 'ga:{0}'.format(team['ga_org_id']), 'start-date': start_date, # start_date.strftime('%Y-%m-%d'), 'end-date': 'today', 'metrics': 'ga:users', # 'dimensions': 'ga:eventLabel', # 'filters': filters, 'max-results': app_config.GA_RESULT_SIZE, 'samplingLevel': app_config.GA_SAMPLING_LEVEL, 'start-index': 1, } return GoogleAnalytics.query_ga(params)
def get_user_data(self, team, start_date=None): """ Get the number of users in the last seven days """ if not start_date: start_date = '90daysAgo' params = { 'ids': 'ga:{0}'.format(team['ga_org_id']), 'start-date': start_date, # start_date.strftime('%Y-%m-%d'), 'end-date': 'today', 'metrics': 'ga:users', # 'dimensions': 'ga:eventLabel', # 'filters': filters, 'max-results': app_config.GA_RESULT_SIZE, 'samplingLevel': app_config.GA_SAMPLING_LEVEL, 'start-index': 1, } return GoogleAnalytics.query_ga(params)
def get_slug_message(self, slug, story=None): # Try to match the story to a slug to accurately get a team # The Google Analytics property ID comes from the team config # We use the default team if none is found stories = Story.select().where(Story.slug.contains(slug)) team = self.config.get_team_for_stories(stories) params = self.get_slug_query_params(team=team, slug=slug) data = GoogleAnalytics.query_ga(params) if not data.get('rows'): logger.info('No rows found for slug %s' % slug) return # Clean up the data clean_data = self.clean_data(data.get('rows')) total_people = self.get_total_people(clean_data) friendly_people = "{:,}".format(total_people) # Comma-separated #s median = self.get_median(clean_data) # Set up the chart scroll_histogram_url = self.get_chart(clean_data) if story: scroll_histogram_url = ChartTools.add_screenshot_to_chart(story, scroll_histogram_url) # TODO: Not confident in median calculations so far # text = "*%s people* got a median of *%s percent* down the page." % (friendly_people, median) text = '' attachments = [{ "fallback": slug + " update", "color": "#eeeeee", "title": "How far down did people scroll?", "image_url": scroll_histogram_url }] return { 'text': text, 'attachments': attachments }