Thursday, 10 June 2021

Adjust Hyperlink Parameters while sending an Email via Marketing Campaign

Introduction

Using below steps you can add additional URL parameters with dynamic values to your Hyperlink which was created in Content Studio Form.

Also you can define a custom field on the campaign level from which you can influence the behavior of few parameters which you set in BADI, or also you can add new link parameters using this custom field.

Implementation.

1. go to Custom Fields and Logic App

2. go to Tab Custom Fields

3. Create a custom field in Business Context Marketing: Campaign

SAP ABAP Exam Prep, SAP ABAP Tutorial and Material, SAP ABAP Career, SAP ABAP Preparation

Now goto Campaigns App > Create > Email Campaign > Create

1. now click on Profile
2. and click Adapt UI

SAP ABAP Exam Prep, SAP ABAP Tutorial and Material, SAP ABAP Career, SAP ABAP Preparation

1. right click anywhere on the campaign header section
2. click on Add Field, this will open a popup, select the custom field which was created under campaign in the first step and click OK
3. that will add the custom field on campaign header
4. click SAVE & Exit on top so that the UI adaptation is visible to all users who use Campaign

SAP ABAP Exam Prep, SAP ABAP Tutorial and Material, SAP ABAP Career, SAP ABAP Preparation

1. now goto Custom Fields and Logic app and Custom Logic
2. First we need to activate Add Block Attributes BAdI where we can define the fields which we further need in next BADI for our logic.
3. Next we have to activate Adjust Hyperlink Parameters While sending Emails BAdI to define the logic to Adjust parameters.

SAP ABAP Exam Prep, SAP ABAP Tutorial and Material, SAP ABAP Career, SAP ABAP Preparation

In Add Block Attributes BAdI define all the fields which you would like to further use in Hyperlink Parameter BAdI.

Sample Code from Add Block Attributes BAdI

Append 'DA-_SAP_CF_CE_CONTACT_IA_ERP_CUST-YY1_TARGET_CODE_MPS' to ct_attributes .
Append 'DA-_SAP_CF_CE_CONTACT_IA_ERP_CUST-CONTACT_KEY' to ct_attributes .
Append 'BO-CUAN_INITIATIVE-YY1_LINKURL_MIN' to ct_attributes .
Append 'DA-_SAP_CF_CE_CONTACT_IA_ERP_CUST-IC_MKT_AREA_ID' to ct_attributes .
Append 'DA-_SAP_CF_CE_CONTACT_IA_ERP_CUST-COUNTRY' to ct_attributes .
Append 'DA-_SAP_CF_CE_CONTACT_IA_ERP_CUST-LANGUAGE_CODE' to ct_attributes .

Sample Code from Adjust Hyperlink Parameters While Sending Emails

DATA: ls_utm_parameter       TYPE cuan_me_s_parameter,  "if_cuan_cmsg_adapt_hyperlinks=>cuan_me_s_parameters.
ls_block_attribute     TYPE cuan_me_s_parameter.

IF link_append_url_param = abap_true.

*   How to set a simple URL parameter
ls_utm_parameter-attribute = if_cuan_cmsg_hyperlink_const=>gc_url_source.
ls_utm_parameter-value     = 'newsletter' . "if_cuan_cmsg_hyperlink_const=>gc_url_value-source.
APPEND ls_utm_parameter TO link_parameter.
CLEAR  ls_utm_parameter.

*   How to set an URL parameter by reading something from Block attribute BADI
LOOP AT block_attributes INTO ls_block_attribute WHERE attribute = 'DA-_SAP_CF_CE_CONTACT_IA_ERP_CUST-YY1_TARGET_CODE_MPS'.
ls_utm_parameter-attribute = 'TARGET_CODE'.
ls_utm_parameter-value     = ls_block_attribute-value .
APPEND ls_utm_parameter TO link_parameter.
CLEAR :ls_utm_parameter,ls_block_attribute.
ENDLOOP.

*   How to set an URL Parameter based on the value entered in the custom field on Campaign header
LOOP AT block_attributes INTO ls_block_attribute WHERE attribute = 'BO-CUAN_INITIATIVE-YY1_LINKURL_MIN'.
ls_utm_parameter-attribute = 'Custom_param'.
ls_utm_parameter-value     = ls_block_attribute-value .
APPEND ls_utm_parameter TO link_parameter.
CLEAR :ls_utm_parameter,ls_block_attribute.
ENDLOOP.

ENDIF."link append url parameter check

How to Test the functionality


1. create an Email in Content Studio with BI/BE Seg profile
2. Add some link
3. and give a valid URL
4. also make sure to Check Google Analytics Parameter as the whole BADI logic executes only if this parameter in checked.

SAP ABAP Exam Prep, SAP ABAP Tutorial and Material, SAP ABAP Career, SAP ABAP Preparation

Use Above created Email in an Email Campaign and run the campaign to your mail ID.

in the mail which you receive, the link will have additional parameters which was added from the BAdI logic.

No comments:

Post a Comment