Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "analyticsLabel" as a config option for CTAs #749

Open
rosiegrant opened this issue May 4, 2020 · 0 comments
Open

Add "analyticsLabel" as a config option for CTAs #749

rosiegrant opened this issue May 4, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@rosiegrant
Copy link
Contributor

Our analytics events optionally accept a ctaLabel attribute. Right now, the only way for an admin to configure this is by entirely overwriting eventOptions, but to do so, they need to add in a lot of logic (whether it's on vertical / universal, the entity Id, etc).

We should expose this label attribute as a top level config option so it's easier to use it.

  • Defaults to null
  • Should accept either a string, or a function that takes in the result data.
  • If present, should be passed as ctaLabel attribute as a part of eventOptions, like this:
    image

Here's what callsToAction would look like:

const callsToAction = [{
  // Label below the CTA icon, default null
  label: 'cta label',
  // Icon name for the CTA that is one of the built-in icons, defaults to undefined (no icon). If your icon
  // is not recognized it will default to 'star'.
  icon: 'star',
  // URL to a custom icon for the cta. This takes priority over icon if both are present, default is
  // no icon url.
  iconUrl: 'https://urltomyicon.com/customicon.gif',
  // Click through url for the icon and label
  // Note, a protocol like https:// is required here.
  url: 'https://yext.com',
  // Analytics event that should fire, defaults to 'CTA_CLICK':
  //       'TITLE_CLICK',
  //       'CTA_CLICK',
  //       'TAP_TO_CALL',
  //       'ORDER_NOW',
  //       'ADD_TO_CART',
  //       'APPLY_NOW',
  //       'DRIVING_DIRECTIONS',
  //       'VIEW_WEBSITE',
  //       'EMAIL',
  //       'BOOK_APPOINTMENT',
  //       'RSVP'
  analytics: 'CTA_CLICK',
  //NEW, passed as a ctaLabel for the event.
  analyticsLabel: 'My CTA Label',
  // The target attribute for the CTA link, defaults to '_blank'. To open in a new window use '_blank'
  target: '_blank',
  // The eventOptions needed for the event to fire. Either a valid json string, an object, or a function that
  // takes in the result data response.
  // By default, if no event options are specified the SDK will try to add verticalKey, entityId, and searcher options
  // to the analytics event.
  eventOptions: result => {
    return {
      // The vertical key for the CTA. If unspecified, this defaults to the vertical key this cta is a part of
      verticalKey: "people",
      // The entity id of the result this cta is a part of, defaults to the entityId field in Knowledge Graph
      entityId: result.id,
      // If the CTA is inside a vertical search, defaults to the value "VERTICAL",
      // if is inside a universal search, defaults to the value "UNIVERSAL"
      searcher: "VERTICAL",
      //ADDED - passed as a ctaLabel for the event.
      ctaLabel: "My label",
    };
  }
}]
@rosiegrant rosiegrant added the enhancement New feature or request label May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant