Command Your Brand with Dynamic Branding

If you create custom login pages with Visualforce and Apex controllers, you can now control how your login page appears and behaves to users at run time. For example, you can specify which logo appears depending on whether the user is an employee or customer. Or you can invoke different registration processes or different consent flows. This change applies to both Lightning Experience and Salesforce Classic.
Available in: Group, Professional, Enterprise, Performance, Unlimited, and Developer Editions

To implement the user’s dynamic login experience, retrieve the value of the Experience ID cookie (expid) stored in the user’s browser. You retrieve the expid value with the getExperienceId Apex method of the System.Site class.

Set the value of the expid cookie by either:

  • Passing in the expid dynamic parameter on the login page
  • Extending a supported endpoint with the expid_value


You can extend these endpoints:

  • community-url/services/oauth2/authorize/expid_value
  • community-url/idp/endpoint/HttpPost/expid_value
  • community-url/idp/endpoint/HttpRedirect/expid_value

Example

This example passes expid_expid_value as a hint in the OAuth endpoint, where expid_value is expid_printer.

image of endpoint with the expid highlighted

The getExperienceId method returns printer—excluding “expid_.” To signal the app’s printer signal, you pass it as expid_printer. The value retrieved is printer.

The getExperienceId method appears in the login controller.

   global CustomLoginController()
   {
      orgId = UserInfo.getOrganizationId();
      if (startURL == null) startURL = ‘/’;
      
      expId = Site.getExperienceId();
   }

The custom login page contains the code to get the value of the Experience ID.

   </div>
   <div class="{!expId}" id="brand">
      <apex:outputText value="Expid: {!expId}"></apexoutputText>
   </div>
   <div class="links">