Here's how to install and configure a client library or REST.
Prerequisites
Before installing a client library, complete the steps in Set up API access, including configuring Application Default Credentials (ADC).
Install library
On your local machine, install the client library of your choice:
REST
Choose the type of setup process you want to follow:
- Update the placeholders in the following sample, such as OPERATING_ACCOUNT_PRODUCT, OPERATING_ACCOUNT_ID, and AUDIENCE_ID, with the values for your account and destination.
- Replace PROJECT_ID with the ID of your Google Cloud.
Copy the sample to the command line to send the request.
#!/bin/bash # Uses gcloud to get an access token. If the Application Default # Credentials aren't for a service account, the command that specifies # --scopes fails. This sample falls back to the command without the # --scopes argument. DATA_MANAGER_ACCESS_TOKEN="$(gcloud auth application-default print-access-token --scopes=https://www.googleapis.com/auth/datamanager || \ gcloud auth application-default print-access-token)" # Fetches and prints the scope information for the access token. If you # get scope-related errors when you send the request in the next step, # verify that this output includes the Data Manager API scope: # https://www.googleapis.com/auth/datamanager curl https://www.googleapis.com/oauth2/v1/tokeninfo?access_token="${DATA_MANAGER_ACCESS_TOKEN}" # Sends the request. curl -X POST "https://datamanager.googleapis.com/v1/audienceMembers:ingest" \ --header "Authorization: Bearer ${DATA_MANAGER_ACCESS_TOKEN}" \ --header "x-goog-user-project: PROJECT_ID" \ --header "Content-Type: application/json" \ --data @- <<EOF { "destinations": [ { "operatingAccount": { "accountType": "OPERATING_ACCOUNT_TYPE", "accountId": "OPERATING_ACCOUNT_ID" }, "loginAccount": { "accountType": "LOGIN_ACCOUNT_TYPE", "accountId": "LOGIN_ACCOUNT_ID" }, "productDestinationId": "AUDIENCE_ID" } ], "audienceMembers": [ { "userData": { "userIdentifiers": [ { "emailAddress": "07e2f1394b0ea80e2adca010ea8318df697001a005ba7452720edda4b0ce57b3" }, { "emailAddress": "1df6b43bc68dd38eca94e6a65b4f466ae537b796c81a526918b40ac4a7b906c7" } ] } }, { "userData": { "userIdentifiers": [ { "emailAddress": "2ef46c4214c3fc1b277a2d976d55194e12b899aa50d721f28da858c7689756e3" }, { "emailAddress": "54e410b14fa652a4b49b43aff6eaf92ad680d4d1e5e62ed71b86cd3188385a51" }, { "emailAddress": "e8bd3f8da6f5af73bec1ab3fbf7beb47482c4766dfdfc94e6bd89e359c139478" } ] } }, { "userData": { "userIdentifiers": [ { "emailAddress": "05bb62526f091b45d20e243d194766cca8869137421047dc53fa4876d111a6f0" }, { "emailAddress": "f1fcde379f31f4d446b76ee8f34860eca2288adc6b6d6c0fdc56d9eee75a2fa5" } ] } }, { "userData": { "userIdentifiers": [ { "emailAddress": "83a834cc5327bc4dee7c5408988040dc5813c7662611cd93b707aff72bf7d33f" }, { "emailAddress": "223ebda6f6889b1494551ba902d9d381daf2f642bae055888e96343d53e9f9c4" } ] } } ], "consent": { "adUserData": "CONSENT_GRANTED", "adPersonalization": "CONSENT_GRANTED" }, "encoding": "HEX", "termsOfService": { "customerMatchTermsOfServiceStatus": "ACCEPTED" }, "validateOnly": true } EOF
.NET
Install the client library
Follow the instructions in the .NET client library installation guide to add a dependency to the client library in your project.
Optional: Get the utility library and code samples.
Clone the GitHub repository.
git clone https://github.com/googleads/data-manager-dotnet.gitIn your .NET project, declare a
ProjectReferencedependency on the utility library. Replace PATH_TO_UTILITY_LIBRARY with the location where you cloned thedata-manager-dotnetrepository.<ProjectReference Include="PATH_TO_UTILITY_LIBRARY\Google.Ads.DataManager.Util\src\Google.Ads.DataManager.Util.csproj" />To format data, use the
Formatterutility in your .NET project.Browse code samples in the
samplessubdirectory or on GitHub.Change to the
samplesdirectory and usedotnet runto get the list of available samples.dotnet runPass the
--helpargument when running a sample to print a usage statement with expected parameters.dotnet run -- ingest-audience-members --helpTo help you get started with some sample data, use the file at
samples/sampledata/audience_members_1.csv.
Java
Install the client library
Follow the instructions in the Java client library installation guide to add a dependency to the client library in your project.
Optional: Get the utility library and code samples.
Clone the GitHub repository.
git clone https://github.com/googleads/data-manager-java.gitNavigate to the
data-manager-javadirectory.Build and publish the utility library to your local Maven repository.
./gradlew data-manager-util:installIn your Java project, declare a dependency on the utility library.
Gradle:
implementation 'com.google.api-ads:data-manager-util:0.2.0'Maven:
<dependency> <groupId>com.google.api-ads</groupId> <artifactId>data-manager-util</artifactId> <version>0.2.0</version> </dependency>To format and encrypt the data, use the
UserDataFormatterandEncrypterutilities in your Java project.Browse code samples in the
data-manager-samplessubdirectory or on GitHub. To run a sample from the command line, use the Gradleruntask.For example, the following command runs the
IngestAudienceMemberssample and prints a usage statement:./gradlew data-manager-samples:run \ --args='IngestAudienceMembers --help'To help you get started with some sample data, use the file at
data-manager-samples/src/main/resources/sampledata/audience_members_1.csv.
Node.js
Install the client library
Follow the instructions in the Node.js client library installation
guide to add a dependency to the
@google-ads/datamanager client library in your project.
Optional: Get the utility library and code samples.
Clone the GitHub repository.
git clone https://github.com/googleads/data-manager-node.gitNavigate to the
data-manager-nodedirectory.Run the following command to install dependencies.
npm installChange to the
utildirectory.cd utilRun the following command to compile and pack the utility library into a
.tgzfile for use withnpm.npm packThe command generates an archive named
google-ads-datamanager-util-0.2.0.tgz. Take note of the file location so you can use it in the next steps.In your Node.js project, declare a dependency on the Data Manager API utility library by adding a
dependenciesentry for the full path and filename of thegoogle-ads-datamanager-util-0.2.0.tgzfile.{ "dependencies": { ... "@google-ads/data-manager-util": "file:PATH_TO_UTILITY_LIBRARY/google-ads-datamanager-util-0.2.0.tgz", ... } }To format data, use the
UserDataFormatterutility in your Node.js project.Browse code samples in the
samplessubdirectory or on GitHub. Run the samples using the following steps:Navigate to the
data-manager-nodedirectory.Run the samples, passing any required arguments. Pass the
--helpargument when running a sample to print a usage statement with expected parameters.For example, the following command runs the
ingest_audience_memberssample and prints a usage statement:npm run ingest-audience-members -w samples -- --help
To help you get started with some sample data, use the file at
samples/sampledata/audience_members_1.csv.
PHP
Install the client library
Follow the instructions in the PHP client library installation
guide to add a dependency to the
googleads/data-manager client library in your project.
Optional: Get the utility library and code samples.
Clone the GitHub repository.
git clone https://github.com/googleads/data-manager-php.gitNavigate to the
data-manager-phpdirectory.Run the following command to resolve dependencies for the library:
composer update --prefer-distIn the
composer.jsonfile of your PHP project on the same host, declare a dependency on the utility library using the following steps:Add an entry in the
repositoriessection that points to the location of thedata-manager-phpdirectory."repositories" : [ { "type" : "path", "url" : "PATH_TO_UTILITY_LIBRARY" } ]Declare a dependency on the utility library.
"require": { "googleads/data-manager-util": "@dev" }
To format data, use the
Formatterutility in your PHP project.Browse code samples in the
samplessubdirectory or on GitHub. Run the samples using the following steps:Navigate to the
samplesdirectory.Run the following command to resolve dependencies for the library:
composer update --prefer-distRun the samples, passing any required arguments. Pass the
--helpargument when running a sample to print a usage statement with expected parameters.
To help you get started with some sample data, use the file at
samples/sampledata/audience_members_1.csv.
Python
Install the client library
Follow the instructions in the Python client library installation
guide to add a dependency to the
google-ads-datamanager client library in your project.
Optional: Get the utility library and code samples.
Clone the GitHub repository.
git clone https://github.com/googleads/data-manager-python.gitNavigate to the
data-manager-pythondirectory.To install the utility library in your Python environment, run the following command:
pip install .In your Python project, declare a dependency on the utility library. For example, if using a
requirements.txtfile in your project, add the following line to the file:google-ads-data-manager-util=0.2.0To format and encrypt the data, use the
FormatterandEncrypterutilities in your Python project.Browse code samples in the
samplessubdirectory or on GitHub. To run samples, install the necessary dependencies:pip install .[samples]Pass the
--helpargument when running a sample to print a usage statement with expected parameters.To help you get started with some sample data, use the file at
samples/sampledata/audience_members_1.csv.
Ruby
Install the client library
Follow the instructions in the Ruby client library installation guide to add a dependency to the client library in your project.
Next steps
- Learn more about sending audience data.
- Learn more about sending events.
- Browse the REST or RPC reference documentation.