ToolBox -

dsSearchAgent Mobile: Redirecting Users From Your Site

dsSearchAgent Mobile provides a way to automatically redirect visitors using compatible mobile devices from a website you control to the mobile home search interface. By default, it will prompt the user to redirect instead of redirecting immediately. If the user chooses not to redirect, a small yellow button is added to the bottom-left area of the page that they can use to hop to the mobile search interface if they change their mind.

Basic Redirect Code

For the impatient, here’s the code used to make this basic functionality happen. It’s designed to be placed within the <head> tag of your site template so that it can be used on all the pages of the site. Note: You’ll need to replace the 1234 next to accountId with your account ID and the 56 next to searchSetupId with the ID of the MLS you want to use. You can get those values by either a) looking at the URL you were given for your dsSearchAgent Mobile page (first number is account ID, second is MLS ID) or b) emailing us at [email protected] and asking for that information.

<script>
  var _ds_midx;
  if (!_ds_midx) {
    _ds_midx = {
      accountId: 1234,
      searchSetupId: 56
    };
    (function() {
      var r = document.createElement('script');
      var s = document.getElementsByTagName('script')[0];
      r.async = true;
      r.src = 'http://midx.diverse-cdn.com/modules/redirector.js';
      s.parentNode.insertBefore(r, s);
    })();
  }
</script>

Landing Screen / Page After Redirect

The screen of dsSearchAgent Mobile that the user is sent to upon redirect varies depending on the URL they were visiting immediately before the redirect. For most URLs, the user will be redirected to the “Home” screen. However, when the user has visited either a page created by dsIDXpress or a page that has dsSearchAgent framed on it, they’ll be redirected to the set of properties or individual property that would have been displayed otherwise. In other words, if the user was on a URL that shows “123 Main Street” on either dsIDXpress or dsSearchAgent, they’ll be redirected to that same “123 Main Street” property in dsSearchAgent Mobile. Similarly, if they were on a dsIDXpress or dsSearchAgent URL that shows all condos in the city of Irvine priced under $400k, they’ll be redirected to those same results with that same filtering criteria in dsSearchAgent Mobile.

Adjusting the Landing Screen

If your visitor would normally be redirected to the “Home” screen and you’d rather have then redirected to a view of properties, you can set the defaultRedirectLinkId property. The value for that property should be a link ID you created in your control panel. For now at least, you can find that value by looking at the URL when editing a link. In the future, we may provide an easier way to get that value.

If you’d like to use this functionality, here’s an example of what your redirect script should look like:

<script>
  var _ds_midx;
  if (!_ds_midx) {
    _ds_midx = {
      accountId: 1234,
      searchSetupId: 56,
      defaultRedirectLinkId: 789
    };
    (function() {
      var r = document.createElement('script');
      var s = document.getElementsByTagName('script')[0];
      r.async = true;
      r.src = 'http://midx.diverse-cdn.com/modules/redirector.js';
      s.parentNode.insertBefore(r, s);
    })();
  }
</script>

Configuration Options

As mentioned, the redirect code is designed so that you can place it in your site template and have it used on all the pages of your site. However, we understand that, while you want it in the template for ease-of-maintenance, you may want certain URLs to not show the redirect prompt, not show the yellow button, and / or immediately redirect when the user lands on the page. We provide some configuration options within the code to help you accomplish that goal.

The configuration options are implemented in a JavaScript object literal under the urlConfig property of the _ds_midx variable. If you don’t know what that means, don’t fret! Let’s start by taking a look at a fully built-out example.

Example

<script>
  var _ds_midx;
  if (!_ds_midx) {
    _ds_midx = {
      accountId: 1234,
      searchSetupId: 56,
      urlConfig: {
        // custom listing, community, and office roster pages seem like they might not be a good thing to offer a redirection on
        '/(listings|communities|office-roster)/*': {
          action: 'NeverPrompt',
          dontRenderUi: true,
          patternSyntax: 'Regex'
        },
        // let's pretend you have another idx where the information isn't transferred to dsSearchAgent Mobile on redirect
        '/non-diverse-solutions-crummy-idx/*': {
          action: 'NeverPrompt',
          dontRenderUi: true,
          patternSyntax: 'Wildcard'
        },
        // all dsIDXpress pages start with /idx/, so let's redirect immediately
        '/idx/*': {
          action: 'ImmediateRedirect'
        },
        // if you have dsSearchAgent framed on this page, you might want to redirect immediately
        '/my-dssearchagent-page/': {
          action: 'ImmediateRedirect',
          patternSyntax: 'WildcardCaseSensitive'
        }
      }
    };
    (function() {
      var r = document.createElement('script');
      var s = document.getElementsByTagName('script')[0];
      r.async = true;
      r.src = 'http://midx.diverse-cdn.com/modules/redirector.js';
      s.parentNode.insertBefore(r, s);
    })();
  }
</script>

Defining A Config

Now let’s take a look at each item within that urlConfig object. You’ll see that the keys are strings that represent URLs on your site and the values are objects representing the config for that URL representation. The urlConfig property can have as many or as few of these configs as you’d like. They’re always processed in order from top to bottom, and the first one matched will always take precedence.

Let’s examine the keys for each option. Each key is intended to match a URL using the matching method defined by that option’s patternSyntax property. The available patternSyntax options are Regex, WildcardCaseSensitive, and Wildcard (default). The filter / key is applied to the entire URL that the visitor is on; if the match is successful, that config is used.

Config Options

Each config item has a number of options that can apply to the URL if it’s matched.

  • action: The action defines whether the user is prompted to redirect, immediately redirected without choice, or not prompted at all. The corresponding option values are Auto (default), ImmediateRedirect, or NeverPrompt.
  • dontRenderUi: If set to true, the button that appears at the bottom-left of the page when the user isn’t prompted or doesn’t want to redirect won’t be displayed. We may decide to change this to something other than a button at some point, in which case this option will also disable whatever else we add or change the button to.
  • patternSyntax: As already mentioned, the value for this defines how the URL is matched and can be one of Regex, WildcardCaseSensitive, and Wildcard (default).

Reasons to use the above configuration options

If you are adding the “Basic Redirect Code” to the <head> of your web site and the modification is applied to all pages of your web site. This means that the prompt to switch to dsMobile will display on ever page of your web site (unless “Cancel” is already selected and your mobile device remembers your settings). In this case, you can use the “action: NeverPrompt” syntax to never show the dsMobile prompt on a specific page (i.e. office roster, community info pages, etc.).

Suppressing Prompts and Redirects

If desired, it’s possible to temporarily suppress both the immediate and prompted redirect functionality by changing the URL. To do so, simply add a dsidx-force-full=1 parameter to the URL. The prompt / redirect functionality will be disabled until the next time the user’s browser is closed and then re-opened. See below for examples.

Note that, even with this parameter, the “View Mobile Property Search” button will still appear in the bottom-left of the page on supported mobile and tablet devices.