Working with Knowledge Tags
Our Knowledge Tags feature lets you bring the power of schema to your webpage. Use schema from Yext to prime your webpage for the intelligent services of the future. Don’t waste time creating schema that conforms to Schema.org’s standards when we can do it for you quickly and automatically.


Knowledge Tags basics


Knowledge Tags have three main features:
  • Schema: Add perfect, always-up-to-date schema to a webpage for a location or person.
  • Knowledge Sync: Sync the content on a website with the Yext Knowledge Engine so that the visible content stays current.
  • Analytics: Pull basic website analytics from a webpage into Yext Analytics.
You can implement Knowledge Tags in minutes by following the steps below.

Get started

KnowledgeTags1
1. In the Yext platform, go to the “Knowledge Tags” page (Pages > Knowledge Tags), and click Add Knowledge Tags to Website.

KnowledgeTags2
2. You’ll be prompted with a large dialogue box. Simply follow the flow to add Knowledge Tags to your page and keep your content in sync with Yext.

KnowledgeTags3
3. Click More Fields to see all of the fields that you have access to. You can also copy and paste the code for each field by clicking directly on the embed code!

KnowledgeTags4

Scan your page

1. To scan your page, click Scan URL.

KnowledgeTags5
2. You’ll be prompted to enter a URL that you would like to scan. Once that’s done, we’ll inform you of whether or not your schema was correctly installed and which schema was found.

View your pages

To see the pages on which you’ve used Knowledge Tags, refer to the bottom of the “Knowledge Tags” page:

KnowledgeTags7
You can observe websites on which we’ve received activity—meaning that a user viewed that page with Knowledge Tags active—and the date on which we received that last activity. If the date is further behind than you expect, you should check in on that website! Also, you can scan that page easily with the Scan URL button in that row.

Knowledge Tags for developers

While Knowledge Tags are meant to be simple for anyone to set up, we’ve included a number of advanced features to make it easy for developers to customize the implementation to meet on their needs.

Script tag

Let’s start with the the script tag. Putting the script tag in your page’s markup is the first step in setting up Knowledge Tags.
<script async defer src="https://knowledgetags.yextpages.net/embed?key=<SECRET_KEY>&account_id=<ACCOUNT_ID>&location_id=<LOCATION_ID>" type="text/javascript"></script>

The script tag contains the following parameters:

SECRET_KEY
The secret key is only used to enable the Knowledge Tags JavaScript implementation. It does not function as a typical API key found in your Developer Console and CANNOT be used interchangeably with those keys. This secret key can ONLY be found in the Knowledge Tags section of the Yext platform.

LOCATION_ID
The location ID (called “Store ID” in the Yext Platform) identifies the location whose data is included in the schema. You can easily replace this ID dynamically; you do not need to go back to the Yext platform and copy a new script tag. When you change the LOCATION_ID on a webpage, the script will automatically update.

ACCOUNT_ID
The account ID is the ID of the account. For regular accounts, this value does not change. If you are using the Partner Portal, the ACCOUNT_ID is the ID that can be found in the “Yext Customer ID” column in the Partner Portal, corresponding to a particular client.

Embed tags

Embed tags allow you to update visible content on the page with content from the Yext Knowledge Engine. Think of it as using the Yext Knowledge Engine as your webpage CMS. To retrieve data from Yext, set the value of data-yext-field to the appropriate field. See the example for the Business Address field below:
<span data-yext-field="address1"></span>

Common fields

The list below shows the fields commonly used in Knowledge Tags. Note that not all fields work on spans; make sure you use the correct HTML tag for each field.
  • Business Name
    • Name of your location in the Knowledge Engine
    • data-yext-field value – name
    • HTML tag – span
    • Embed tag – <span data-yext-field="locationName"></span>
  • Logo
    • The logo image for your location
    • data-yext-field value – logo.url
    • HTML tag – img
    • Embed tag – <img data-yext-field="logo.url"></img>
  • Store ID
    • The Store ID of your location
    • data-yext-field value – id
    • HTML tag – span
    • Embed tag – <span data-yext-field="id"></span>
  • Business Description
    • A short description of your location
    • data-yext-field value – description
    • HTML tag – span
    • Embed tag – <span data-yext-field="description"></span>
  • Contact Email
    • The main email address for your business
    • data-yext-field value – email
    • HTML tag – span
    • Embed tag – <span data-yext-field="email"></span>
  • Business Address
    • The street address of your locations
    • data-yext-field value – address1
    • HTML tag – span
    • Embed tag – <span data-yext-field="address1"></span>
  • Business Floor / Suite / Unit
    • The floor, suite, or unit of the building where you location can be found (if applicable)
    • data-yext-field value – address2
    • HTML tag – span
    • Embed tag – <span data-yext-field="address2"></span>
  • Business City
    • The city or locality your location is in
    • data-yext-field value – city
    • HTML tag – span
    • Embed tag – <span data-yext-field="city"></span>
  • Business State
    • The state or region your location is in
    • data-yext-field value – state
    • HTML tag – span
    • Embed tag – <span data-yext-field="state"></span>
  • Business Postal Code
    • The postal code for your location (applies to US locations only)
    • data-yext-field value – zip
    • HTML tag – span
    • Embed tag – <span data-yext-field="zip"></span>
  • Business Country
    • The country code (two-character ISO 3166-1) of the location’s country
    • data-yext-field value – countryCode
    • HTML tag – span
    • Embed tag – <span data-yext-field="countryCode"></span>
  • Business Phone
    • The phone number for your location, automatically formatted based on the location’s country
    • data-yext-field value – phone
    • HTML tag – a or span
      • When the a tag is used, the phone number is displayed as a link that, when clicked, dials the number in the device’s phone app (if applicable).
      • When the span tag is used, the phone number is displayed as text.
    • Embed tag – <a data-yext-field="phone"></a>
  • Payment Methods
    • A comma-separated list of payment methods accepted at your location
    • data-yext-field value – paymentOptions
    • HTML tag – span
    • Embed tag – <span data-yext-field="paymentOptions"></span>
  • Business Hours
    • Hours of operation, for all days (e.g., “Monday through Friday, 9 AM – 6 PM”)
    • data-yext-field value – hours
    • HTML tag – div
    • Embed tag – <div data-yext-field="hours"></div>
  • Business Hours (specific day of the week)
    • Hours of operation, for a particular day of the week (e.g., “Sunday 10 AM – 4 PM”)
    • data-yext-field value – hours-<day>
    • HTML tag – span
    • Example embed tag – <span data-yext-field="hours-monday"></span>
  • Google Places link
    • Google Places link for your location (default link text: “Get Directions”)
    • data-yext-field value – get-directions-link
    • HTML tag – a
    • Embed tag – <a data-yext-field="get-directions-link"></a>
      • To customize the link text, enter the text between the a tags.

    Other available fields

    While we most frequently see Knowledge Tags for the fields listed above, you can also create a Knowledge Tag for any text Location field. If you’re creating a Knowledge Tag for a field that contains a URL (e.g., uberLink), use the a HTML tag:
    <a data-yext-field="uberLink"></a>
    
    For a complete list of Location fields, see the Locations: Get response.

    In addition to Location fields, custom fields are available in Knowledge Tags. To create a Knowledge Tag for a custom field, use the following embed code format:
    <[HTML_TAG] data-yext-field="customFields.[ID]"></[HTML_TAG]>
    
    where [ID] is the id of the custom field and [HTML_TAG] is a or span. Custom field IDs can be found in the customFields Location field or in responses to Custom Fields: List requests.

    List fields

    In addition to text Location fields, you can also use any list field in Knowledge Tags. Any field in Knowledge Manager that stores a list of values can be rendered as visual content on your page with an embed tag. This feature gives you the ability to create Knowledge Tags for fields like products, services, specialities, and brands.

    When styling your list, you can use the following HTML tags:
    • <ul> — creates a bulleted list
    • <ol> — creates a numbered list
    • <span> — creates a comma-separated list on one line
    • <div> — creates a series of <div> elements, each on a separate line

    For example, to display a bulleted list of your products, you would use the following embed tag:
    <ul data-yext-field="products"></ul>
    You can also create Knowledge Tags for custom fields that contain lists:
    <ul data-yext-field="customFields.23456"></ul>
    For more details about displaying custom-field content with embed tags, see the “Other available fields” section of this guide.

    Styling Tags

    Use CSS to style the tags on your page. None of the Knowledge Tags have CSS associated with them, so if you have already styled your page, replacing static content with embed codes should not affect your site’s appearance.

    Server-Side Tags

    Knowledge Tags use JavaScript to dynamically replace the content client-side and are designed to render very quickly with little to no flicker. However, if you want to implement Knowledge Tags on the server side, you can use our Live API directly. For more information on the Live API, see our Using the Live API guide.

    Multi-Language Knowledge Tags

    If you’re using our Multi-Language Profile feature, you can use the lang query parameter to specify the profile that a page’s Tags should retrieve content from.

    For example, the code below retrieves content from the location’s French profile (lang=fr):
    <script async defer src="https://knowledgetags.yextpages.net/embed?key=<SECRET_KEY>&account_id=<ACCOUNT_ID>&location_id=Paris&lang=fr" type="text/javascript"></script>

    Note that any embedded content in the Tags’ fields will be provided in the specified language, as well.

    Multiple locations on a single page

    You will mostly likely use Knowledge Tags on a single location page. If you have a page that shows information about multiple locations, you will need to add markup for each location. You can easily do so by adding multiple location_Id values to the script tag:
    <script async defer src="https://knowledgetags.yextpages.net/embed?key=<API_KEY>&account_id=<ACCOUNT_ID><location_id=<STORE_ID1>&location_id=<STORE_ID2>" type="text/javascript"></script>
    

    When providing additional location_Id values, make sure each of your tags also includes a data-yext-location-id property that specifies which location’s data should be used in the tag:
    <span data-yext-field="address1" data-yext-location-id="123456"></span>
    

    Schema manipulation

    If you want to make other manual adjustments to the schema, you can use our Schema API directly. The Schema API is a server-side API that returns a JSON schema object. It is up to you to add this JSON-LD object to the webpage once you retrieve it, but adding it allows you to manipulate the JSON in order to customize it exactly how you want it. While doing so may be useful in some situations, changing the schema is generally not recommended. Knowledge Tags schema will be updated automatically as schema definitions change, so you should not assume that the JSON-LD object you put directly into your page’s markup will remain current over time. For more information on the Schema API endpoint, see the Live API documentation.

    Analytics

    By default, page views will be tracked automatically when you add the Knowledge Tags script to a webpage. Additionally, the number of times users click or tap “Call” or “Get Directions” on a location’s page will also automatically be tracked if you use the standard corresponding embed codes. To track more events, you can use our JavaScript library directly. To trigger an event through your own JavaScript, follow the model below:
    Yext.customEvent("EVENT_NAME", "LOCATION_ID")
    
    If you want to call the standard events (“Get Directions” or “Phone Call”) via the JavaScript library, use the following event names:

    GET_DIRECTIONS
    Yext.customEvent("GET_DIRECTIONS", "LOCATION_ID")
    

    TAP_TO_CALL
    Yext.customEvent("TAP_TO_CALL", "LOCATION_ID")
    

    More about Knowledge Tags

    For more information about Knowledge Tags, watch our video tutorial series.

    Knowledge Tags and Knowledge Sync



    Schema API



    Knowledge Tags and WordPress