Automatically Sync Event Attendees to Hubspot

What this Zap does

When your event ends in CE-Go, this Zap automatically syncs all attendees to HubSpot as Contacts—no more manual data entry!

Before you start

Make sure you have:

  • A CE-Go account with at least one event
  • A HubSpot account (Free or any paid plan)
  • Super Admin permissions in your HubSpot account

⏱️ Time to set up: About 15-20 minutes


Setup Steps

Step 1: When Event Ends

  1. Create new Zap → Search CE-Go
  2. Select Event Ended trigger
  3. Connect your CE-Go account
  4. Click Test trigger

Step 2: Setup Configuration

  1. Add Code by ZapierJavaScript
  2. In Input Data, add:
    • event_id1. Event ID
    • total_users1. Total Users
  3. Paste this code:
// =============================================
// 🔧 Don't change below
// =============================================

const limitPerPage = 100;
const eventId = inputData.event_id;
const totalUsers = inputData.total_users;
const totalPages = Math.ceil(totalUsers / limitPerPage);

const pages = [];
for (let i = 1; i <= totalPages; i++) {
  pages.push(i);
}

return { 
    event_id: eventId,
    total_users: totalUsers,
    limit: limitPerPage,
    pages: pages,
    total_pages: totalPages
};

Step 3: Check if Users Exist

  1. Add Filter by Zapier
  2. Set: 2. Total Users(Number) Greater than0

Step 4: Loop Users Page by Page

  1. Add Looping by Zapier
  2. Action: Create Loop From Line Items
  3. Values to Loop: pages2. Pages
  4. Trim Whitespace: True
  5. Loop counter start: 1
  6. Maximum iterations: 100

Step 5: Get Event Users

  1. Add CE-GoGet Event Users
  2. Configure:
    • Event ID: 2. Event Id
    • Limit: 2. Limit
    • Page: 4. Loop Iteration
    • If multiple results: Return all results as line items

Step 6: Skip if No Users on Page

  1. Add Filter by Zapier
  2. Set: 5. Count(Number) Greater than0

Step 7: Format Contacts for HubSpot

  1. Add Code by ZapierJavaScript
  2. In Input Data, add: data5. Step(Row) Output
  3. In Input Data, add: loop_iteration → 4. Loop Iteration
  4. Paste this code:
try {
  const data = JSON.parse(inputData.data);
  const users = data.results;

  // Create batch contacts for HubSpot
  const contacts = users.map(user => {
    return {
      id: user.email.toLowerCase().trim(),  // email as id
      idProperty: "email",                   // specify that id is email
      properties: {
        email: user.email.toLowerCase().trim(),
        firstname: user.first_name || "",
        lastname: user.last_name || "",
        phone: user?.address?.phone || ""
        // Add custom fields here
        // company: user.company || ""
      }
    };
  })
  .slice(0, 100); // HubSpot batch limit

  return {
    contacts: JSON.stringify(contacts),
    count: contacts.length,
    page_number: inputData.loop_iteration
  };
} catch(e) {
  return {
    error: true,
    message: e.message
  };
}

Step 8: Sync to HubSpot

  1. Add HubSpotAPI Request (Beta)
  2. Configure:
Field Value
Stop on error Yes
HTTP Method POST
URL https://api.hubapi.com/crm/v3/objects/contacts/batch/upsert
Additional request headers Key: Content-Type
Value: application/json
Body
{
  "inputs": <strong>{{7. Contacts}}</strong>
}
		

⚠️ Important: Make sure to add the Content-Type: application/json header and map {{7. Contacts}} as a field (not as text in quotes).

Step 9: Validate Results

  1. Add Code by ZapierJavaScript
  2. In Input Data:
    • hubspot_response8. Response Body
    • page_number7. Page Number
  3. Paste this code:
try {
  // Parse HubSpot response from Step 8
  const response = JSON.parse(inputData.hubspot_response);
  
  // Check if response exists
  if (!response) {
    return {
      error: true,
      error_title: "No Response from HubSpot",
      message: "HubSpot API did not return a response",
      page_number: inputData.page_number
    };
  }
  
  // Extract results and errors from HubSpot response
  const results = response.results || [];
  const errors = response.errors || [];
  const status = response.status || "UNKNOWN";
  
  // Count successful and failed records
  const successfulCount = results.length;
  const failedCount = errors.length;
  const totalProcessed = successfulCount + failedCount;
  
  // Collect error details if any
  const errorDetails = errors.map(err => ({
    category: err.category || 'UNKNOWN',
    message: err.message || 'No error message',
    id: err.id || 'N/A',
    status: err.status || 'N/A'
  }));
  
  // Check if all records failed
  if (failedCount > 0 && successfulCount === 0) {
    return {
      error: true,
      error_title: "All Contacts Failed",
      message: `All ${failedCount} contacts failed to sync`,
      successful_count: 0,
      failed_count: failedCount,
      error_details: errorDetails,
      batch_status: status,
      page_number: inputData.page_number
    };
  }
  
  // Check for partial success
  if (failedCount > 0 && successfulCount > 0) {
    return {
      error: true,
      status: "partial_success",
      successful_count: successfulCount,
      failed_count: failedCount,
      total_processed: totalProcessed,
      error_details: errorDetails,
      hubspot_ids: results.map(r => r.id),
      batch_status: status,
      page_number: inputData.page_number
    };
  }
  
  // Full success
  return {
    error: false,
    status: "success",
    successful_count: successfulCount,
    failed_count: 0,
    total_processed: totalProcessed,
    hubspot_ids: results.map(r => r.id),
    batch_status: status,
    page_number: inputData.page_number
  };
  
} catch (error) {
  return {
    error: true,
    error_title: "Failed to Validate HubSpot Response",
    message: error.message,
    page_number: inputData.page_number
  };
}

🎉 Publish Your Zap

  1. Review all steps
  2. Click Publish at the top right
  3. Your Zap is now live!

Success! Attendees will now automatically sync to HubSpot when events end.


💡 Troubleshooting

Error Solution
"Failed to create a http request" Make sure you added the Content-Type: application/json header in Step 8
"Invalid input JSON" Check that the Body in Step 8 uses mapped field {{7. Contacts}}, not text in quotes
"Some required fields were not set" Verify that id, idProperty, and email are present in Step 7 code
"INVALID_EMAIL" Some emails are invalid. Valid contacts will still be created
Duplicate contacts HubSpot automatically handles duplicates by email - existing contacts will be updated

Adding Custom Fields

In Step 7 code, add fields inside the properties object:

properties: {
  email: user.email.toLowerCase().trim(),
  firstname: user.first_name || "",
  lastname: user.last_name || user.email.split("@")[0],
  phone: user.phone || "",
  company: user.company || "",
  custom_field: user.custom_value || ""
}

Note: Custom field names must match HubSpot property internal names (not labels).


Need Help?

Happy syncing! 🎉
You've just automated your HubSpot CRM workflow!

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us