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
- Send yourself the required file for this tutorial
- Check your inbox
- Download the attachment from the email when it arrives
- 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
- Sign in to x10Hosting (or create a free account)
- Click the Open cPanel button
- 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
- Click Switch to cPanel x3 (or click Keep cPanel x3)
- Under Files, click File Manager
- If Directory Selection pops up, select Web Root (public_html/www) then click Go
- Click the Upload icon in the top menu
- Click Choose File
- Find and select the distribute-hubspot-leads-evenly.php file
- Wait until you see “complete” in the bottom-right status
- 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
- Click distribute-hubspot-leads-evenly.php to highlight it in blue
- Click the Code Editor icon
- 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
- Go to https://app.hubspot.com/keys/get
- You might need to log in to HubSpot
- Click Generate New Key (or View Key)
- Click Copy to clipboard
- Go back to your Code Editor tab
- 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”.
In the left sidebar, click on “Users”.
You will be taken to a screen that looks like this.
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.
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.
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.)
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
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:
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.
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”.
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
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: