Get started

The getting started procedure documented here is specific to accessing Ad Targeting within Secure Research Environment. Secure Research Environment runs a modified version of Jupyter and provides you with a virtual data cleanroom where you can securely search for and analyze data. The following sections guide you through getting up and running with Ad Targeting in Secure Research Environment:

Log in to the Secure Research Environment URL

Use one of the two available Amazon WorkSpaces Secure Browser portals to access Ad Targeting in Secure Research Environment. For the best user experience and platform performance, select the Secure Browser portal closest to your location:

See WorkSpaces Secure Browser in the Secure Research Environment user documentation for more information about WorkSpaces Secure Browser.

Log into the site using your Facebook credentials. This will spin up an instance of JupyterHub server for your use in Secure Research Environment.

You will be offered the choice of CPU or GPU server. See GPU server to learn about the difference between the two. See Secure Research Environment for complete Secure Research Environment documentation.

Create a Jupyter notebook

In the Launcher window, click the icon for Python3 or R. This will create a new Jupyter notebook in a new browser tab. To rename the notebook, right-click on the notebook in the left navigation bar and select Rename.

Import the query module

Import our query module (execute) by clicking in an empty notebook cell and entering the following code:

library(fbrir)
from fbri.private.sql.query import execute

Run the code by clicking the run button in the top toolbar. Initially you will not see anything happen. A new notebook cell appears when it finishes importing the query module.

Test with a simple SQL query

Enter the following code in the empty notebook cell to define a SQL query (sql) using variable substitution (database and table), and use the query module to execute the query:

library(fbrir)
athena = AthenaFacade$new()

database <- "fbri_prod_atp"
table <- "ad_targeting_dataset_siep_aug_2020"
api_table <- "ad_archive_api"

# Define your own SQL query and assign to variable 'sql' 
sql <- sprintf("SELECT * FROM %s.%s LIMIT 5", database, table)
athena$QueryAthena(sql)
from fbri.private.sql.query import execute

database = "fbri_prod_atp"
table = "ad_targeting_dataset_siep_aug_2020"
api_table = "ad_archive_api"

# Define your own SQL query and assign to variable 'sql' 
sql = f"SELECT * FROM {database}.{table} LIMIT 5"

execute(sql)

Run the code. This should return a dataframe of your results, similar to those shown below (screenshots of dataframe results blurred intentionally).

The dataframe result from the R example would look similar to this (blurred intentionally):



The dataframe result from the Python example would look similar to this (blurred intentionally):



You can scroll within the dataframe to see additional table columns.

Next steps

Performing the query above verifies that you are able to perform a basic search by using our web application. We recommend that you read a few sample queries to get an idea of how to build your own custom queries.