3rd Party Integrations - Datorama

This article is a guide for integrating TAM reporting data into Datorama

Updated over a week ago

Teads Ad Manager reporting data does not have a native connector in Datorama. However, there is a workaround using Datorama's Python Data Stream feature to download a scheduled TAM report.

Follow the steps below in order to do this:

  1. Create a scheduled report in Teads Ad Manager:

    • Navigate to the Reports tab in TAM, and then click on "New report".

    • Choose the relevant dimensions and metrics that you want to see in Datorama - make sure you select Day as your first dimension, then select Recurrent as the schedule, Every Day as the frequency, and Previous day for the period.

    • Choose CSV for the Report File Type

    • Click "Save and Run" and wait for your report to be saved.

  2. Create a new Data Stream in Datorama:

    A new Data Stream in Datorama is needed in order to retrieve the results for the report defined in Teads Ad Manager.

    • Login to Datorama, then navigate to Connect & Mix > Data Streams > Data Streams List.

    • Click on "Add New" to start creating a new stream and then choose Python from the Technical Vendors list.

    • Give your Data Stream a name, and use Ads as the Data Stream Type and Display as the Default Channel Name.

    • The next step is to copy and paste the following code into Datorama:

    • import csv, urllib2, urllib, datorama, json

      # Change the following values
      TAM_API_KEY = 'XXXX-XX-XX-XXXX-XXXX'
      TAM_SCHEDULED_REPORT_ID = 'XXXX'
      TAM_SCHEDULED_REPORT_TIMEZONE = 'America/New_York'

      # Do not edit beyond this point
      TAM_API_HOSTNAME = 'https://ads.teads.tv'
      headers = {'Authorization': TAM_API_KEY, 'Content-Type': 'application/json', 'Accept': 'application/json'}

      try:
      req = urllib2.Request(TAM_API_HOSTNAME + "/api/reports/" + TAM_SCHEDULED_REPORT_ID + "/latest-file", None, headers)
      response = urllib2.urlopen(req)
      res = json.loads(response.read())
      if res['url']:
      csvUrl = urllib2.urlopen(res['url'])
      cr = csv.reader(csvUrl)
      cr1 = []

      for row in cr:
      row[0] = row[0].replace(TAM_SCHEDULED_REPORT_TIMEZONE, '')
      cr1.append(row)

      datorama.add_rows(cr1)
      datorama.save()

      except Exception, e:
      print "An error occured: ", str(e)

      Python 2.7

      import datorama, csv, urllib, json, urllib.request, codecs

      # Change the following values
      TAM_API_KEY = 'XXXX-XX-XX-XXXX-XXXX'
      TAM_SCHEDULED_REPORT_ID = 'XXXX'
      TAM_SCHEDULED_REPORT_TIMEZONE = 'America/New_York'

      # Do not edit beyond this point
      TAM_API_HOSTNAME = 'https://ads.teads.tv'
      headers = {'Authorization': TAM_API_KEY, 'Content-Type': 'application/json', 'Accept': 'application/json'}

      try:
      req = urllib.request.Request(TAM_API_HOSTNAME + "/api/reports/" + TAM_SCHEDULED_REPORT_ID + "/latest-file", None, headers)
      response = urllib.request.urlopen(req)
      res = json.loads(response.read())
      if res['url']:
      csvUrl = urllib.request.urlopen(res['url'])
      cr = csv.reader(codecs.iterdecode(csvUrl, 'utf-8'))
      cr1 = []

      for row in cr:
      row[0] = row[0].replace(TAM_SCHEDULED_REPORT_TIMEZONE, '')
      cr1.append(row)

      datorama.add_rows(cr1)
      datorama.save()

      except Exception as e:
      print("An error occured: ", str(e))

      Python 3.6

    • Before pasting, ensure that you have replaced the following values:

      • TAM_API_KEY - this is your Teads Ad Manager API key. If you don't have one, see this article to find out how to generate one.

      • TAM_SCHEDULED_REPORT_ID - this is the report ID for the report we generated in Step 1

      • TAM_SCHEDULED_REPORT_TIMEZONE - this is the timezone for the report we generated in Step 1

    • After pasting the code in Datorama, click on "Validate" to ensure that everything is well.

    • Use Daily as the Frequency and 6am as the delivery hour. Under Advanced settings, please check that the Data Load Mode is set to Replace (this should be the default).

    • Click on "Next" in Datorama

  3. Validate the mapping:

    • Verify that the mapping is accurate. Revisit step #1 and amend your report by incorporating any omitted dimensions or metrics if required.

    • Once done, click "Save" and Datorama will proceed with an initial data import.

Did this answer your question?