Skip to Content
Technical Articles
Author's profile photo Amshuman Aravind Sagar

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

Now goto Campaigns App > Create > Email Campaign > Create

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

  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

  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.

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.

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.

 

Conclusion

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. 🙂

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Kunal Kumar Bansal
      Kunal Kumar Bansal

      Very helpful and nicely explained, Amshuman 👍

      Author's profile photo Satheesha Nayak
      Satheesha Nayak

      Nice one Amshu

      Author's profile photo Prakasha BadeGowda
      Prakasha BadeGowda

      How to copy  campaign custom field URL to Lead internal notes if there is any BADI for it ?.

      Author's profile photo Tobias Schneider
      Tobias Schneider

      Again pretty cool blog post Amshuman, works perfectly! 🙂

      Author's profile photo Simon Wallis
      Simon Wallis

      Hi Amshuman thanks for this blog post - appreciate you wrote it a while ago now but was just wondering if you could advise how you worked out the field name to put in the Add Block Attributes BAdI (BO-CUAN_INITIATIVE-YY1_LINKURL_MIN)

      I have created my own field with context Marketing: Campaign and tried copying as per the prefix / suffix you have used (BO-CUAN_INITIATIVE-YY1_MYFIELDNAME_MIN) but when running no value gets picked up.  I've applied all possible permissions to the field and added it to the Campaign UI.  Any pointers as to where I might be going wrong?

      Author's profile photo Simon Wallis
      Simon Wallis

      Figured it out [by reading the manual :-)]  For future reference create an email in content studio, add the custom attribute to some content, then check the HTML for the underlying name.  It was the same as I thought above - I have no idea why it wasn't working before, but it is now.

      Thanks again for the blog!  Really useful.