Go to Teads Ad Manager

Teads Ad Manager reporting data does not have a native connector in Datorama. But there is a workaround that we will elaborate in this tutorial, using Datorama's Python Data Stream feature to download a scheduled TAM report.


Step 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.


Step 2 - Create a new Data Stream in Datorama:

Now we need to create a new Data Stream in Datorama in order to retrieve the results for the report that we have 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, make sure you replace 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 make sure 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).

Now we're ready to move to the next step - click on "Next" in Datorama.


Step 3 - Validate the mapping:

Check that the mapping is OK. This would also be a good time to go back to step #1 and update your report to add any missing dimensions or metrics.

Once you are happy with it, click "Save". Datorama will do an initial data import.

Congratulations, you are now able to analyze your Teads Ad Manager reporting data into Datorama!

Did this answer your question?