Title: Click tracking Switch
Last modified: September 20, 2023

---

# Click tracking Switch

 *  Resolved [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/click-tracking-switch/)
 * In the past I was instructed to add this code inorder to augment the email call
   for Sendgrid.
 *     ```wp-block-code
       add_filter( 'wp_mail_smtp_providers_mailer_get_body', function ( $body, $mailer ) {
   
        if ( $mailer === 'sendgrid' ) {
         $body['template_id'] = 'templateId';
        }
   
        return $body;
       }, 10, 2 );
       ```
   
 * I am now in need to add another parameter and am unsure of how to do that. Here
   is php code from the sendgrid API reference.
 *     ```wp-block-code
       $tracking_settings = new TrackingSettings();
       $click_tracking = new ClickTracking();
       $click_tracking->setEnable(true);
       $click_tracking->setEnableText(false);
       $tracking_settings->setClickTracking($click_tracking);
       ```
   
 * Any chance you can show me how to add these parameters to my call.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [Victoria Sakal](https://wordpress.org/support/users/sakalvictoria/)
 * (@sakalvictoria)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/click-tracking-switch/#post-17066986)
 * Hi, [@iperez_genius](https://wordpress.org/support/users/iperez_genius/)!
 * Thanks for getting in touch.
 * You can’t use the code from the documentation, since we have self API integration
   and we don’t use SendGrid SDK.
 * You can check all available options that you can add to the request body [here](https://docs.sendgrid.com/api-reference/mail-send/mail-send#body).
 * For example, if you want to enable click link tracking as you shared in the code
   snippet from documentation, you will need to add the next code after the `$body['
   template_id'] = 'templateId';` line in the current code snippet:
 *     ```
       $body['tracking_settings']['click_tracking']['enable'] = true;
       $body['tracking_settings']['click_tracking']['enable_text'] = false;
       ```
   
 * Here is a full code snippet that you should get:
 *     ```
       add_filter( ‘wp_mail_smtp_providers_mailer_get_body’, function ( $body, $mailer ) {
        if ( $mailer === 'sendgrid' ) {
         $body['template_id'] = 'templateId';
         $body['tracking_settings']['click_tracking']['enable'] = true;
         $body['tracking_settings']['click_tracking']['enable_text'] = false;
        }
        return $body;
       }, 10, 2 );
       ```
   
 * Kind regards.
 *  Thread Starter [iperez_genius](https://wordpress.org/support/users/iperez_genius/)
 * (@iperez_genius)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/click-tracking-switch/#post-17068513)
 * Thank you for the fast reply. I have tested this and it works. One more quick
   thing. I need to get the email address that is being sent to.
 * would i get that with $body[“email”]?
 *  Plugin Support [Victoria Sakal](https://wordpress.org/support/users/sakalvictoria/)
 * (@sakalvictoria)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/click-tracking-switch/#post-17069581)
 * Hi, [@iperez_genius](https://wordpress.org/support/users/iperez_genius/)!
 * Thanks for following up.
 * The email can have several “To” recipients and they are stored in the `$body['
   personalizations'][0]['to']` array. Here is an example of how to get the first
   recipient’s email address: `$body['personalizations'][0]['to'][0]['email']`.
 * Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Click tracking Switch’ is closed to new replies.

 * ![](https://ps.w.org/wp-mail-smtp/assets/icon-256x256.png?rev=1755440)
 * [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin](https://wordpress.org/plugins/wp-mail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-smtp/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Victoria Sakal](https://wordpress.org/support/users/sakalvictoria/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/click-tracking-switch/#post-17069581)
 * Status: resolved