Adjust Hyperlink Parameters while sending an Email via Marketing Campaign
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.
- go to Custom Fields and Logic App
- go to Tab Custom Fields
- Create a custom field in Business Context Marketing: Campaign
Now goto Campaigns App > Create > Email Campaign > Create
- now click on Profile
- and click Adapt UI
- right click anywhere on the campaign header section
- 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
- that will add the custom field on campaign header
- click SAVE & Exit on top so that the UI adaptation is visible to all users who use Campaign
- now goto Custom Fields and Logic app and Custom Logic
- 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.
- Next we have to activate Adjust Hyperlink Parameters While sending Emails BAdI to define the logic to Adjust parameters.
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 .
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
- create an Email in Content Studio with BI/BE Seg profile
- Add some link
- and give a valid URL
- also make sure to Check Google Analytics Parameter as the whole BADI logic executes only if this parameter in checked.
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.
In the similar way like explained above, you can create multiple custom fields on Campaign header or you can set some specific rule on how to enter the data in the custom field and build any required logic in the BAdI using these inputs from custom fields.
Example, If the value in Custom field is ‘X’ then delete certain URL Parameters, OR if the value in ‘ALL’ then set all the URL Parameters.
Please share yours thoughts or feedback by leaving a comment below. 🙂