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
symantecAPsymantecAP 

Capture how many times the link was clicked

Hi All I have a formula field  which updates a hyperlink on the field called " JOB AIDE" on Case Object  the link is 

"http://abcdef.com. 

I want to track if the link was clicked.How many times and possibly who clicked it. So that I can report on it.

 

Thanks in advance

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

You can't track these natively, but you could build that into the system. I've outlined a small example of how this might be done.

 

Custom Page:

 

<!-- Page: Redirect -->
<apex:page controller="redirectController" action="{!redirect}">
  This page is used for page redirections. If you are seeing this message, it means the link was incorrectly configured. Please contact your administrator.
</apex:page>

Custom Controller:

 

 

 

public class RedirectController {
  public ApexPages.PageReference redirect() {
    String Url = ApexPages.currentPage().getParameters().get('url');
    if(url==null || url=='')
      return null;
    ApexPages.PageReference ref = new ApexPages.PageReference(url);
    Tracker__c tracker = new Tracker__c(Url__c=url);
    insert tracker;
    ref.setRedirect(true);
  }
}

Custom Object: Tracker

 

 

 

Name Field: AutoNumber
Custom Field: Url__c (type: URL)

Custom links would be changed (__URL__ is the original URL, escaped, __FRIENDLYNAME__ is the display name):

 

 

 

HYPERLINK( "/apex/Redirect?url=" & __URL__, __FRIENDLYNAME__ )

Hopefully this gives you an idea of how you might implement it.

 

 

The object itself would have OwnerId set to the person that clicked the link, Created Date is when they clicked on the link, and URL is the link that was clicked.

 

Of course, you could make this a lot more complex, like a second custom object to track the types of pages or URLs (to allow rollup summary fields), some other fields to track ownership and assign the records to an administrator (so users can not see/delete the data). I leave such modifications as an exercise for the reader.

 

Edit: Updated the link to the correct value.

All Answers

sfdcfoxsfdcfox

You can't track these natively, but you could build that into the system. I've outlined a small example of how this might be done.

 

Custom Page:

 

<!-- Page: Redirect -->
<apex:page controller="redirectController" action="{!redirect}">
  This page is used for page redirections. If you are seeing this message, it means the link was incorrectly configured. Please contact your administrator.
</apex:page>

Custom Controller:

 

 

 

public class RedirectController {
  public ApexPages.PageReference redirect() {
    String Url = ApexPages.currentPage().getParameters().get('url');
    if(url==null || url=='')
      return null;
    ApexPages.PageReference ref = new ApexPages.PageReference(url);
    Tracker__c tracker = new Tracker__c(Url__c=url);
    insert tracker;
    ref.setRedirect(true);
  }
}

Custom Object: Tracker

 

 

 

Name Field: AutoNumber
Custom Field: Url__c (type: URL)

Custom links would be changed (__URL__ is the original URL, escaped, __FRIENDLYNAME__ is the display name):

 

 

 

HYPERLINK( "/apex/Redirect?url=" & __URL__, __FRIENDLYNAME__ )

Hopefully this gives you an idea of how you might implement it.

 

 

The object itself would have OwnerId set to the person that clicked the link, Created Date is when they clicked on the link, and URL is the link that was clicked.

 

Of course, you could make this a lot more complex, like a second custom object to track the types of pages or URLs (to allow rollup summary fields), some other fields to track ownership and assign the records to an administrator (so users can not see/delete the data). I leave such modifications as an exercise for the reader.

 

Edit: Updated the link to the correct value.

This was selected as the best answer
symantecAPsymantecAP

Thank you so much for the approach. I am stuck at a point here. Let me show what i have done 

I have created a custom object Tracker and did the following 

 

<apex:page controller="RedirectController" action="{!redirect}">
 
</apex:page>

 

public class RedirectController {

    public ApexPages.PageReference redirect() {
     String Url = ApexPages.currentPage().getParameters().get('url');
    if(url==null || url=='')
     return null;
    ApexPages.PageReference ref = new ApexPages.PageReference(url);
   URL_Tracker__c tracker = new URL_Tracker__c( Job_Aide_URL__c=url);
    insert tracker;
    
        ref.setRedirect(true);
        return ref;
          
    }

}

 and my formula field is 

 

HYPERLINK("/Tracker/?url="&"http://powerpositions.cars.com/dealers/DMI/DmiFinal.html" , "Job Aide"  , " " ) 

 

But the error i see is "URL NO LONGER EXISTS. You have attempted to reach a URL that is no longer in salesforce

 

 

 

 

symantecAPsymantecAP

I have attached that as /apex/Tracker and it works great..

Thank you. U r the best.. u made me a hero 

sfdcfoxsfdcfox

You're welcome! I updated the link. I can't believe had I had such a simple typo. Well, I'm glad that I was able to help you with your inquiry.

Manpreet Singh 207Manpreet Singh 207
Hello All,

I understand this is an old thread but giving it a shot. I would like to track (capture name and date/time) the number of clicks on embedded link in our visualforce page. On a high level I think, i will need to create a custom object which will have custom fields

1) Lookup field on user object to capture user name
2) Date/Time field to capture Date/time details

Below mentioned is the embedded link in our visualforce page.

<b><p style="font-size:15px"><br>9:00-9:45 AM -- <a href="https://zoom.us/j/XXXXXXXX (https://zoom.us/j/XXXXXXXX" style="color:#0563c1; text-decoration:underline)">Yoga with XXXX</a></br></p></b> <i><br>This class provides strength and flexibility.</br></i>

Any idea how will i go about writing code?