Distribute HubSpot leads evenly to a sales team

ROI for completing this tutorial

  • Time: 21 minutes
  • Cost: $0
  • Return on investment: 5-20 hours saved every month

Assigning HubSpot leads manually to your sales team can be a big time waster. And it’s difficult to make sure that leads are distributed evenly.

This tutorial will show you how to assign leads automatically so that everyone receives the same number of leads.

Email the file to yourself

  1. Send yourself the required file for this tutorial

  2. Check your inbox
  3. Download the attachment from the email when it arrives
  4. No need to open the downloaded file, just move it to your Desktop

You should now have a file called distribute-hubspot-leads-evenly.php on your computer’s Desktop.

Upload the file

  1. Sign in to x10Hosting (or create a free account)
  2. Click the Open cPanel button
  3. Click Switch Theme in the top-right
    • Click Switch to cPanel x3 (or click Keep cPanel x3)
      • You may need to Sign in and click Open cPanel again
  4. Under Files, click File Manager
    • If Directory Selection pops up, select Web Root (public_html/www) then click Go
  5. Click the Upload icon in the top menu
  6. Click Choose File
  7. Find and select the distribute-hubspot-leads-evenly.php file
  8. Wait until you see “complete” in the bottom-right status
  9. Click the Go Back to “/home/your_username/public_html” link

You should now be looking at your File Manager again. You should see that the distribute-hubspot-leads-evenly.php file has been added.


Open the file in the Code Editor

  1. Click distribute-hubspot-leads-evenly.php to highlight it in blue
  2. Click the Code Editor icon
  3. If you see an option to “Select the character encoding to use when you open this file:”
    • Make sure utf-8 is selected
    • Click the Edit button

The Code Editor should open in a new tab or window.


Add your HubSpot API key to the file

  1. Go to https://app.hubspot.com/keys/get
    • You might need to log in to HubSpot
  2. Click Generate New Key (or View Key)
  3. Click Copy to clipboard
  4. Go back to your Code Editor tab
  5. On line 5, paste your key between the quotation marks


Insert the email addresses of the people you want to assign leads to

Go back to the tab or window where you copied your HubSpot API key.

In the top-right corner, click on your profile picture, which will bring up a menu. On that menu, click on “Settings”.

Screen Shot 2015-10-02 at 8.15.37 AM

In the left sidebar, click on “Users”.

Screen Shot 2015-10-02 at 8.17.35 AM

You will be taken to a screen that looks like this.

Screen Shot 2015-10-02 at 10.44.11 AM

If there is someone that you want to assign leads to who is not currently listed on this Users page, add them by clicking the “Add user” button.

Screen Shot 2015-10-02 at 8.19.17 AM

Once you’ve done that, take a moment to double-check that every person you want to assign leads to is listed on that page as a User for your HubSpot account.

Copy the email address of every person that you want to assign leads to and paste it between the quotation marks on line 8 of your “distribute-hubspot-leads-evenly.php” file. Put a comma (“,”) after every email address except the last one.

Screen Shot 2015-10-02 at 8.21.05 AM

When you paste between the quotation marks on line 8, the format should look something like this:




If you want to add more people in the future, you’ll need to create a User account for them using the “Add user” button and then paste their email just like you did with the others in your “distribute-hubspot-leads-evenly.php” file. (Make sure there’s always a comma after every email address except the last one.)

Save your changes

In your “Code Editor” tab or window, click the “Save” button in the top-right corner. (Always remember to save your changes like this when you are editing files in the Code Editor.)

Screen Shot 2015-10-02 at 8.26.27 AM

You may now close your Code Editor tab or window by clicking the “Close” button in the top-right. You can also just close it like a normal browser window assuming you have saved your changes.

Test the file

Whew! You are all done with editing code in the file. Hopefully that wasn’t too painful for you.

Your “distribute-hubspot-leads-evenly.php” file is now live and ready to go. Let’s test it to see if it works. We’re going to do that by visiting the file in our web browser just like a normal web page.

IMPORTANT: When you run the file, any current Contacts in your HubSpot account that do not currently have an “Owner” will automatically have one assigned to them based on the email addresses you entered on line 8 of the file. These assignments will be distributed evenly among all of the emails you entered.

Determine the URL of the file

Go back to your x10Hosting cPanel tab or window. At the top of the “Stats” section, find your “Main Domain”. It should have the format of: YOURDOMAIN.x10host.com

Screen Shot 2015-10-02 at 8.27.50 AM

Open a new browser tab or window. Type in your Main Domain in the address bar and add the path the your “distribute-hubspot-leads-evenly.php” file. Assuming that you uploaded it to your “public_html” folder like I did in this tutorial, the format for the URL that you type into your address bar will look like this:


Screen Shot 2015-10-02 at 8.29.51 AM

Visit the file like a web page

Once you have typed in the URL correctly, press the Enter key on your keyboard to visit this URL.

It might take a minute or two for this page to load depending on how many unassigned Contacts you had in your HubSpot account. Eventually, you should see a success message.

Screen Shot 2015-10-02 at 8.31.28 AM

Add a few test Contacts in HubSpot and then refresh your “distribute-hubspot-leads-evenly.php” page in your browser. Then, take a look at the test Contacts you created to make sure that the Owners are being assigned correctly.

Schedule the file to run every 15 minutes

Your file is working now. When you create test contacts and then visit the file in your browser, those new contacts should have Owners assigned to them.

But the whole goal of this tutorial is to remove the need for manual lead assignment. So, we are going to set up a schedule for the file so that it runs every 15 minutes (or whatever time interval you want.)

Add a new cron job

A cron job is just a fancy term that essentially means “make something happen repeatedly.”

Go back to your x10Hosting cPanel tab or window. Under the “Advanced” section, click on “Cron Jobs”.

Screen Shot 2015-10-02 at 8.32.58 AM

In the “Add a New Cron Job” section, enter the settings below, then click the “Add New Cron Job” button.

  • Minute: */15
  • Hour: *
  • Day: *
  • Month: *
  • Weekday: *
  • Command: wget http://YOURDOMAIN.x10host.com/distribute-hubspot-leads-evenly.php

Screen Shot 2015-10-02 at 8.35.54 AM

Make sure you replace “YOURDOMAIN” so that it matches your x10Hosting Main Domain.

Please note: If you have more than 10,000 Contacts in your HubSpot account, you are going to need to set your schedule to a less frequent interval like once an hour or twice a day. The reason for this is, HubSpot has daily limits for how many times you can look up information in their system. So if you have more than 10,000 Contacts, use the “Common Settings” dropdown in the “Add a New Cron Job” section to select a time interval that works for you.

Test this new schedule

Create a test Contact in your HubSpot account. Wait 15 minutes, or whatever schedule you set, and then see if the Owner of that contact was assigned correctly.


You’ve done it! Congratulations on completing this tutorial.

As I said at the beginning, it’s important to make sure your incoming leads get distributed evenly to your sales team. And now, as the amount of leads you get increases, you will have no problem getting all of those new leads assigned.

What are you going to do with all this free time now that you don’t have to manually assign leads to your sales team? I hope you’ll be able to focus on the more important areas of your department.

Now that you’ve invested the time to go through this tutorial, you can enjoy the benefit of saving hours and hours every month.


I’d like to thank the following people for giving their support and feedback for this tutorial: