Campaign Standard Integration in AEM

11 / Jul / 2023 by pulkit.vashistha 0 comments

Introduction:

In this comprehensive guide, we will walk you through the end-to-end process of integrating Adobe Campaign Standard into Adobe Experience Manager (AEM) with a real-world use case. You will learn how to seamlessly connect the two platforms and leverage the power of Adobe Campaign’s marketing automation capabilities within AEM. We will cover the steps from setting up the integration, creating projects, generating key pairs, and establishing secure authentication. With a practical use case, we will demonstrate how to retrieve customer profiles, send personalized transactional messages, and seamlessly subscribe users to newsletters. Get ready to unlock the full potential of Adobe Campaign Standard within your AEM environment.

Prerequisites:

  1.  You should have access to Adobe developer console.
  2.  On dev console, you should have access to Adobe Campaign.
  3.  You should have access to Adobe Campaign Standard instance access as well to create campaigns and messages.

Steps to Integrate Adobe Campaign APIs in AEM project

  1. Create an account at the Adobe developer console.
  2. On dev console, create a project and add the Campaign API to it.
  3. Generate key pair in project setup and store the private key from the downloaded config file.
  4. Navigate to the API documentation to see which operations you can perform in Adobe Campaigns via Adobe I/O.
  5. Set up a connection with the campaign standard server using the JWT token to fetch the access token. You can find documentation on how to do this on the developer console.
  6. Now you have the access token, and you can make use of all the available APIs from Adobe I/O.

Steps Explained

1.  Create Project for Campaigns at the Adobe dev console

  1. Navigate to the dev console. If not created the account, create and proceed.
    Create a project for your application.
  2. Once created, add Campaign API to your project. Select Adobe Campaign and then Generate Key pair in the next step.

    config.zip gets downloaded. Public Key Certificate and the private key gets downloaded

  3. After successful API creation, you will land on Adobe Campaign SDK details for your project with Service Account credentials info.
  4. If you go to the last of the page, you can navigate to the API documentation where you can make use of these credentials to access Campaign APIs.Here you can navigate which all operations we can perform in Adobe campaigns via Adobe I/O.

2. Campaigns Standard Authentication

You can set up connection with the campaign standard server using the JWT token to fetch Access Token. (documentation)

From the config we downloaded earlier at the project creation on developer console,
Get and store the private key.

Adobe I/O – setting up API access steps

For implementation reference , check the code below:

Login API Post
//privateKey = RSA private key retrieved earlier 
// orgid = Organization id , techact = Technical Account Id.  
// apikey = Client id, clientsecret = Client Secret 
//AUTH_SERVER_FQDN = "ims-na1.adobelogin.com"  

//Initialize JWT Claims(Payload) 
String[] metascopes = new String[]{"ent_campaign_sdk"}; 
HashMap<String, Object> jwtClaims = new HashMap<>(); 
jwtClaims.put("iss", orgid); 
jwtClaims.put("sub", techact); 
jwtClaims.put("exp", System.currentTimeMillis() / 1000 + 86400L); 
jwtClaims.put("aud""https://" + AUTH_SERVER_FQDN + "/c/" + apikey); 
for (String metascope : metascopes) { 
    jwtClaims.put("https://" + AUTH_SERVER_FQDN + "/s/" + metascope, Boolean.TRUE); 
} 
   
//sign with Private Key 
String jwtToken = Jwts.builder().setClaims(jwtClaims).signWith(RS256, privateKey).compact(); 
   
//Perform HTTP post 
HttpPost authPostRequest = new HttpPost("https://ims-na1.adobelogin.com/ims/exchange/jwt/"); 
authPostRequest.addHeader(CACHE_CONTROL, NO_CACHE); 
List<NameValuePair> params = new ArrayList<>(); 
params.add(new BasicNameValuePair("jwt_token", jwtToken)); 
params.add(new BasicNameValuePair("client_id", apikey)); 
params.add(new BasicNameValuePair("client_secret", clientsecret)); 
authPostRequest.setEntity(new UrlEncodedFormEntity(params)); 
HttpResponse response = httpClient.execute(authPostRequest); 
   
//process response 
HttpEntity entity = response.getEntity(); 
JsonObject jo = new JsonParser().parse(EntityUtils.toString(entity)).getAsJsonObject(); 
return jo.get("access_token").getAsString();

Now that we have the Access Token with Us,

We can make use of all the available APIs from Adobe I/O

3. Retrieve Profiles from Campaign Standard

API documentation

Added cURL, used in demo project, below for reference
Retrieve Profiles

curl --location -g --request GET 'https://mc.adobe.io/{{org_id}}/campaign/profileAndServices/profile' \ 
--header 'X-Api-Key: {{api_key}}' \ 
--header 'Authorization; Bearer {{access_token}}' \ 
--header 'Content-Type: application/json' \ 
--data-raw '{ 
    "ctx": { 
    }, 
    "email""\"\\\"polidew222@agrolivana.com\\\"\"" 
}'

Now we have the APIs in Place.

We have integrated shooting emails from our demo AEM app via Transactional Messaging and subscribing to Newsletter Campaigns on Campaign Standard:

4. Sending Transactional Messages from the AEM app:

API documentation for creating transactional Messages on Campaign standard
Once you have followed the above steps and published & tested your transactional message
You can navigate to the Event configuration of the transactional message and check the Api preview for managing the message via REST Api.

Refer to cURL below, used in our demo AEM app, for reference

Send Transactional Message

curl --location -g --request POST 'https://mc.adobe.io/{{org_id}}/campaign/mctangerinedigiapacptrsd/EVTsampleTransactionalEmail' \ --header 'X-Api-Key: {{api_key}}' \ 
--header 'Authorization; Bearer {{access_token}}' \ 
--header 'Content-Type: application/json' \ 
--data-raw '{ 
    "email""test-u6vse5z1s@srv1.mail-tester.com", 
    "ctx": { 
        "hasInsurance"false, 
        "dob""string127", 
        "lname""Vashistha", 
        "fname""Pulkit" 
    } 
}'

5. Integration of Newsletter Subscription:

Making Use of Adobe I/O we have integrated following Logic for Campaign Standard with the Subscribe to Newsletter Campaign on our AEM application :

In the above component, on the home page User enters the mail id and hits subscribe.
Now on the application layer, we are making use of the following business logic to subscribe users to the Newsletter :

  1. User authentication via JWT to fetch auth token.
  2. Checking if user exists on Campaign Standard user db (Search on linked page=> Sample request to filter profiles on the basis of email)
  3. If not, then create and fetch profile.
  4. If it exists, then store the profile.
  5. Send a transactional message to the mail id.
  6. Use the profile to fetch the subscription URL for the profile from the json => profilejson[0].subscriptions.href
  7. Now use the subscription URL for the User and Pkey for the subscription service in Campaign Standard to subscribe user to Service (use Method 1).

Conclusion:

In conclusion, this article has described how to integrate Adobe Campaign APIs with AEM. The integration allows you to send transactional messages and subscribe users to newsletter campaigns on Campaign Standard. The code examples provided in the article can be used as a starting point for your own integration projects. The integration of Adobe Campaign and AEM provides several benefits, including improved email deliverability, increased engagement, and automated workflows.

Specifically, Adobe Campaign can help you:

  • Improve the deliverability of your emails by providing insights into your email audience and helping you create targeted and personalized messages.
  • Increase engagement with your email subscribers by providing you with tools to track opens, clicks, and other metrics.
  • Automate your email marketing workflows, freeing your time to focus on other tasks.

If you are looking for a way to improve your email marketing, then integrating Adobe Campaign with AEM is a great option. The integration provides a number of benefits that can help you to improve the deliverability, engagement, and automation of your email campaigns.

If you still have questions, comment and join the discussion! Meanwhile, check out our other blog posts: JOSE Encryption and AEM Keystore Integration

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *