Print this page

Exporting Leads with and without tags

Knowledge Article Number 000232347
Description All leads which are assigned to personal / public tags needs to be exported in csv file and also which are not tagged to any of personal / public tags are also can be exported using this method.
Resolution Exporting Lead with or without Tags
Available in: both Salesforce Classic and Lightening Experience.

Available in:
• Enterprise
• Performance
• Unlimited
• Developer

To export records: “Read” on the records
To export all records: “Read” on the records

You can use the Apex Data Loader export wizard to export Leads with or without Tags from Salesforce. When you export, you can choose to include (Export All) or exclude (Export) soft-deleted records.

personal tag page in Salesforce

Go into Setup>> Customize>> Tags >> Tag Settings>> Enable Personal tags/ Enable Public Tags

1. Open the Data Loader.

2. Click Export or Export All. These commands can also be found in the File menu.

3. Enter your Salesforce username and password. Click Log in to log in. After your login completes successfully, click Next. (Until you log out or close the program, you will not be asked to log in again.)

If your organization restricts IP addresses, logins from untrusted IPs are blocked until they’re activated. Salesforce automatically sends you an activation email that you can use to log in. The email contains a security token that you must add to the end of your password. For example, if your password is mypassword, and your security token is XXXXXXXXXX, you must enter mypasswordXXXXXXXXXX to log in.

4. Choose LeadTag object. If your object name does not display in the default list, check Show all objects to see a complete list of objects that you can access. The objects will be listed by localized label name, with developer API name noted in parentheses.

5. Click Browse... to select the CSV file to which the data will be exported. You can enter a newfile name to create a new file or choose an existing file. If you select an existing file, the contents of that file are replaced. Click Yes to confirm this action, or click No to choose another file.

6. Click Next.

7. Create a SOQL query for the data export. For example, check Id and Name in the query fields and click Finish.

a. Choose the fields you want to export.
b. Optionally, select conditions to filter your data set. For example if you want to export all records under this tag name exist than you can pull out Tag Id against that Tag and create a filter as shown in Screenshot below.
If you do not select any conditions, all the data to which you have read access will be returned.
c. Review the generated query and edit if necessary.
Tip: You can use a SOQL relationship query to include fields from a related object.

8. Click Finish, then click Yes to confirm.

9. A progress information window reports the status of the operation.

10. After the operation completes, a confirmation window summarizes your results. Click View Extraction to view the CSV file, or click OK to close.  And result looks as below:

exported tag list screenshot

After you finished exporting LeadTags you need to use Data Loader to export All Leads by following Steps 4 to 8 once again for Lead object and save file with different name.

We then require opening LeadTags.csv and AllLeads.csv file. Use Vlookup function in Microsoft Excel to insert tag name and tag id into AllLeads.csv file.
Insert a new column in “AllLeads.csv” file

Apply vlookup formula in AllLeads.csv new column to find leads id in LeadTags.csv file item id column and pull out tag name /tag id against it. See below :
=VLOOKUP("002Q8000004d10K", A2:B16, 2, FALSE)
1st - The first argument is the name of the item you're searching for
2nd - The second argument is the cell range that contains the data in another sheet.

Note: It's important to know that VLOOKUP will always search the first column in this range.
3rd - The third argument is the column index number to pull from table and returned by formula. The first column in the range is 1; the second column is 2, etc.
4th - The fourth argument tells VLOOKUP whether to look for approximate matches, and it can be either TRUE or FALSE. 
Your file is complete now with All leads with & without tags. Use excel filter to identify.
Repeat above steps of Vlookup to insert tag id column in All Leads.csv file. When done, you can use filter on tagname/ tagid fields to identify only those records of leads which are tagged and cut them and paste them in separate file . In that way you will have two files of Leads records with and without tags.

Related References:
Browsing, Searching, and Managing Tags


promote demote