You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在Pardot中配置Webhook?实现Prospect退订时触发POST请求

How to Trigger a POST Request to Your Website When a Prospect Unsubscribes in Pardot

Great question—since Pardot (now Salesforce Marketing Cloud Account Engagement) doesn’t have that one-click webhook setup like Mailchimp, we can use its built-in automation tools to replicate this exact functionality. Here are two reliable, actionable methods:


Method 1: Use Automation Rules with "Send Post Message" (No-Code Approach)

This is the quickest way to get up and running if you’re using the modern Pardot/MCAE interface:

  1. Prepare your website’s POST endpoint
    First, make sure your site has a publicly accessible endpoint that can accept POST requests (e.g., https://yourdomain.com/webhooks/pardot-unsubscribe). It should be able to parse incoming JSON payloads with prospect details like email, ID, etc.

  2. Build the Automation Rule in Pardot

    • Head to Automation > Automation Rules in your Pardot dashboard.
    • Click Add Automation Rule and name it something clear, like "Trigger Unsubscribe POST to Website".
    • Under Rule Criteria, set the condition to:

      Prospect > Unsubscribed > is > True

    • Scroll to the Actions section, find and select Send Post Message.
    • Configure the request details:
      • URL: Paste your website’s endpoint URL.
      • Request Method: Choose POST.
      • Request Body: Use Pardot merge fields to pass relevant data (example: {"email":"{{prospect.email}}","prospect_id":"{{prospect.id}}","unsubscribe_timestamp":"{{date_time}}"}).
      • Authentication (if needed): Add headers for API keys or tokens if your endpoint requires verification.
  3. Test the workflow
    Manually unsubscribe a test prospect in Pardot, then check your endpoint logs to confirm the POST request was received successfully.


Method 2: Use Pardot API + Apex (For Salesforce-Integrated Environments)

If you’re running Pardot alongside a full Salesforce org, you can use Apex triggers to listen for unsubscribe sync events:

  1. Ensure Pardot-Salesforce Sync is active
    Confirm your Pardot prospects are syncing to Salesforce Contact/Lead records (this should be enabled by default if you’ve set up the integration).

  2. Write an Apex Trigger
    Create a trigger that fires when a Contact/Lead’s HasOptedOutOfEmail field flips to True (this mirrors Pardot’s unsubscribe status). Use Salesforce’s Http classes to send the POST request. Example snippet:

    trigger UnsubscribeWebhook on Contact (after update) {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://yourdomain.com/webhooks/pardot-unsubscribe');
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json');
    
        for(Contact c : Trigger.New) {
            // Only trigger when the unsubscribe status is newly set
            if(c.HasOptedOutOfEmail && !Trigger.OldMap.get(c.Id).HasOptedOutOfEmail) {
                String payload = JSON.serialize(new Map<String, Object>{
                    'email' => c.Email,
                    'salesforce_contact_id' => c.Id,
                    'unsubscribe_date' => DateTime.now()
                });
                request.setBody(payload);
                HttpResponse response = http.send(request);
                // Add error logging here if you need to debug failures
            }
        }
    }
    
  3. Validate the trigger
    Unsubscribe a test prospect in Pardot, wait for the sync to Salesforce, then check your endpoint logs to confirm the POST request was sent.


Key Tips:

  • Payload Customization: Both methods let you tailor the data sent to your site—use Pardot merge fields (Method 1) or Salesforce fields (Method 2) to pass exactly what you need.
  • Error Handling: For Method 1, check Pardot’s Automation Rule logs if requests fail. For Method 2, add debug logging in Apex to track issues.
  • Security: Always use HTTPS for your endpoint, and add authentication (like API keys in headers) to block unauthorized requests.

内容的提问来源于stack exchange,提问作者Mitsu Chatrola

火山引擎 最新活动