function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mattdmattd 

Tracking web site downloads

I'm working with a client that has their site integrated into SalesForce.  They would like to track when users download files from their site.  These downloads can be down anonymously, or by a logged in user (tied to a SalesForce Lead).  They would like to have this data follow the Lead through convertion into a Contact and/or Opportunity.  In the end they would like to see what people were downloading that eventually lead to a particular Opportunity.

Now, I'm not to savy with SalesForce in the first place, but here is my first solution.
I've created a Custom Object, "Download", with a lookup field tying it to a particular Lead.  I've then added fields for the download information (url, title,...).  I've enabled Reporting on the Custom Object.  This has allowed them to see which Leads have downloaded what and how much.  The problem is that I the information doesn't follow the Lead when it is converted (as Activity History does).

Am I looking at this the wrong way?  How should I track this type of information?

Thanks in advance for your help.
mattdmattd
Another thought was to use Activities to record Download information.  The idea being that "Downloading" is an "Activity".  Then the Activity History would stay with the user through conversion.  Is this the right usage of an Activity?  It seems that Activities are meant to be actions taken by the Sales team rather than the Lead.  If it is a correct use, would I be able to create a "Custom Activity Type" in order to record the Download specific information (url, title,...)?
mattdmattd
Events have a field "Name" that seems to be a lookup of both Leads and Contacts.

Name   Lookup(Contact,Lead)

Does that mean I can specify a Contact of Lead name in the field?  Would I be able to reuse this concept for my "data following" problem.  In other words, could I tie Downloads to a "Contact/Lead" and expect it to travel with a Lead when they convert to a Contact?
Park Walker (TAGL)Park Walker (TAGL)
You're on the right track here, and activities are the easiest way to track lead/contact related activities. The reference to Lead,Contact in the activity indicates that the field can hold either a lead id or a contact id. When you create the activity you set either the lead id or the contact id (not a name, but an id). There is some magic in the application that keeps this linkage when a lead is converted to a contact.

You can add the custom fields you need to the activity and then create a new record type and layout to keep the new fields off the standard activity display. You will probably want to add a new value to the status to use in the download activity records and mark it as a 'closed' status. You'll also want to think about which user to assign the activities to.

The downside to this approach is that it does clutter up the activities with the download activity and makes getting just the download history a little more difficult. The alternative (your initial idea) requires some programming work to link lead related activities to a contact.

Park

Message Edited by Redsummit on 05-16-2007 05:48 AM

mattdmattd
Is it possible to make a custom type of Activity?  I would need to add several fields, but I wouldn't want these fields to be available on all Activities (as that may cause confusion).  Then, when reporting, I would filter Activities based on type before doing analysis.

It is also my understanding that Contacts' Activities can be passed on to Opportunities.  Would the Activity, with the Lead/Contact field be passed on with this same SalesForce magic upon conversion?

Thank you for your reply.  It's taking me a bit to get my head around this.
mattdmattd
I can't seem to figure out how to customize a Task to fit the "Download" type I want.  I've created the Task Record Type of Download.  Then I created two Activity Custom Fields (I did not see how to add a Task Custom Field), URL and Title.  When I try to add a Download Task to a Lead, I don't see how to fill in the URL or Title information.  Am I customizing the Download Task correctly?
Park Walker (TAGL)Park Walker (TAGL)
Tasks and Events are types of Activities; they share common fields but not record types and layouts.

First create two record types, one for regular tasks and one for downloads. This is a bit non-intuitive but the first record type that you create replaces the 'master'. The different record types allow you to keep picklist values seperate from the different record types.

The next step is to create the download layout which will display the fields for these activities.

The third step is to create the new fields for the downloads and have them displayed on the download layout but not the task layout. You should consider not adding a new field for the title and using the Subject field instead. I say this because the Subject field will display in the related lists on contacts and leads by default. If you use a new field for the title you will not be able to see the title unless you add that field to the related lists, and if you do that you will see the field for every task. You might want to prefix the value you put into the Subject with "Download:" or somthing else to distinguish the activity. You may want to add status values and a new type value at this time as well. If you do, you should go back to the record types when you're done and select which picklist values are used for the different record types.

The final step is to use the Page Layout Assignment button on the Activity Page Layout screen to assign the download layout to download records, at least for user profiles that you want to be able to see download activity. It might make sense to assign the layout for all profiles, except that this will require all users to select the record type each time they create a new task which can get annoying. Until you assign different layouts to the different record types you will not be able to choose the record type when you click the 'New Task' button.

Now when you create a new task you should be prompted to choose the record type. Choosing the download type will give you the download layout with your new fields.

Park Walker (TAGL)Park Walker (TAGL)
See my previous response regarding the fields and record types.

While Activities can be associated with Opportunities that needs to happen when they are created. Since Leads have no Opportunities it's pretty tough. The Activities will be associated with the Contact and,if the Contact is associated with the Opportunity, there is a way to get back to them.

Once the conversion takes place you can associate the Activity with an Opportunity (What field) as well as the Contact (Who field) but that means being able to idenitfy the appropriate Opportunity when you create the Activity. If you have multiple Opportunities for an Account/Contact this could be problematic.

Park
666Chicago666Chicago
I have to follow up question. So if you decide to use the activity object to track downloads from a web to lead form.  What would the web to lead form code look like that capatures the download data?  And can a web to lead form put data into a related list?
 
thanks,
 
mattdmattd
Here is what I ended up doing:
  • Inside SalesForce interface (Setup -> Customize...)
    • I made a new 'Task Page Layout' and named it 'Download Page'
    • I made a new 'Task Record Type' and named it 'Download' and used the 'Download Page' layout
    • I made several new 'Activity Custom Fields'
    • I added the fields to the 'Download Page' layout
  • Using SoqlXplorer (I'm on a Mac): http://www.pocketsoap.com/osx/soqlx/
    • I queried to find out my 'Download' RecordTypeId:
      • select id, name from recordtype
      • returned several records
      • I noted the ID for 'Download' and used it in my PHP script
  • In my PHP script
    • I had to use a third party SalesForce API because my client had PHP version < 5
      • http://sourceforge.net/project/showfiles.php?group_id=96634&package_id=166314
    • Below is some basic code I used to create a new 'Download'
    • I used SoqlXplorer again to figure out the names of the fields to populate
Code:
require_once('salesforce/salesforce.php');

$salesForce = new salesforce('salesforce/partner.wsdl.xml');
$login = $salesForce->login($username, $password); // Be sure to set these

if ($login) {
 $email = 'username@example.com'; // Set with business logic
 if ($email != '') {
  $result = $salesForce->query("select id from contact where email = '$email' order by createddate desc");
  if ($result['size'] == 0) $result = $salesForce->query("select id from lead where email = '$email' order by createddate desc");

  if ($result['size'] == 1) $id = $result['records']->id;
  else if ($result['size'] > 1) $id = $result['records'][0]->id;
  else $id = false;
  
  if ($id) {
   $result = $salesForce->create(new sObject('Task', null, array(
    'WhoId' => $id,
    'Subject' => "Download: $category - $title",
    'Download_Type__c' => $category,
    'Download_Title__c' => $title,
    'URL__c' => $url,
    'Status' => 'Completed',
    'RecordTypeId' => '012400000004w9dAAA' // The ID for the 'Download' Task Record Type
   )));
   
   print($result['success'] — 'Download recorded' : 'Error in download record creation');
  } else print("Unknown user");
 } else print('Empty email');
} else print("SalesForce login failed");