Adding CORS headers to DropWizard API

In your DropWizard Application class, add the following to allow the hosts in allowedOrigins to do GET,PUT,POST,DELETE,OPTIONS to your API.

 

Getting up and running with Java API for Google Tag Manager

This tutorial will get you started with using the java google tag manager api, using a google api service account which is added as a user in google tag manager admin.

Please note that you CANNOT push events to Google Tag Manager using the API (like dataLayer.push({}) in JavaScript)! See stackoverflow.com/a/33361837/945506. (This was my goal, but because I struggled with getting things set up, I’m creating this tutorial for people that want to use the API to do other things.)

Step 1 – Create service account

Go to console.developers.google.com, log in, and create a new service account with key type JSON:

The resulting file should look like this:

Step 2 – Grant access to the services account

Go to tagmanager.google.com, log in, go to admin > user management > new.

The email should be identical to the value for the “client_email” key in the file you downloaded in step 1 (accountname@trans-airfoil-1…gserviceaccount.com).

Step 3 – List containers using Java Google API

If you’re using maven, include the com.google.apis.google-api-services-tagmanager package:

If you’re not using maven, see here.

The following code will do a very simple thing, simply list all available container ids attached to the given account id.

What next?

Have a look at API Explorer for ideas on what to do next.