Adding Clickable Links to Q&A Module

I have a healthcare client who would like to add a message to their Q&A Module so that if someone has a time sensitive question, they are not sending it to the Q&A Module but are instead calling the practice directly. The practice does not constantly monitor the Q&A module and does not want anything urgent to get lost.

In the description field for my module, I tried to add:

When I tried to update my preview, I saw the following console error:

Is it possible to add rich text to the Q&A Module? Is there anything I’m missing in my html? Thanks!

Hi Sarah,

You can definitely do this! Because the file is JSON, you’ll just need to take an extra step to make sure the quotes come through correctly.

Try adding the below for your description - using the \ character to ‘escape’ the quotation marks:

 "description": "If this is an urgent matter, please call us at <a href=\"tel:12345678\">12345678</a>.",

Let us know if this helps!

Worked like a charm!! Thank you very much I never would have come up with that.

@afarooque, Is there a way for me to set up conversion tracking with these links within the QA module? I tried setting up tracking for the organization entity, but was not successful. Is there a tag I can set up to track 1) how often these links are clicked and 2) to see who may navigate back to book an appointment after clicking one of these links?

Hey Sarah,

This will require overriding the template to add the custom analytics events.

Whenever you want to make an update to the template of a component, you’ll need to take a few steps to override the template. The Overriding Component Layouts unit has some context, but we’ll walk through the specific example of adding event tracking to the links in the Q&A description. As a note, this will require a good understanding of Handlebars and the Answers Javascript Library to complete successfully.

Adding Custom Partials

The base Question Submission handlebars template can be found in the Answers Javascript Library here: answers-search-ui/questionsubmission.hbs at master · yext/answers-search-ui · GitHub

For this example, we don’t want to change too much of the partial itself, so we’ll use this as a starting point and tweak from there.

First, create two files in your partials folder - customQA-universal.hbs and customQA-vertical.hbs.

image

Next, copy/paste the contents of the Q&A template from the Answers Library above into these two files, as our starting point.

Find where it’s referencing the {{{_config.description}}}. This is injecting what you’ve determined in componentSettings of your page as the description. Here, we’ll hardcode the description in the template itself.

Replace the {{{_config.description}}} line with the below (separate snippets for each file):

customQA-universal.hbs


If you need to contact us urgently, please call toll-free

<a href="tel:1866-800-999"

data-eventtype="TAP_TO_CALL"

data-eventoptions='{"searcher": "UNIVERSAL", "entityId": "ORG-1", "verticalKey": "QASubmission", "ctaLabel": "qa-call"}'> 1-866-800-999</a>,

email

<a href="mailto:help@brand.com"

data-eventtype="EMAIL"

data-eventoptions='{"searcher": "UNIVERSAL", "entityId": "ORG-1", "verticalKey": "QASubmission", "ctaLabel": "qa-email"}'>

help@brand.com

</a>

or use our chat function for immediate support.

customQA-vertical.hbs


If you need to contact us urgently, please call toll-free

<a href="tel:1866-800-999"

data-eventtype="TAP_TO_CALL"

data-eventoptions='{"searcher": "VERTICAL", "entityId": "ORG-1", "verticalKey": "QASubmission", "ctaLabel": "qa-call"}'> 1-866-800-999</a>,

email

<a href="mailto:help@brand.com"

data-eventtype="EMAIL"

data-eventoptions='{"searcher": "VERTICAL", "entityId": "ORG-1", "verticalKey": "QASubmission", "ctaLabel": "qa-email"}'>

help@brand.com

</a>

or use our chat function for immediate support.

The data-eventoptions is passing the relevant data needed to succesfully fire the analytics event. Make sure that the entityId aligns to the ID of your Organization entity that’s linked to the Q&A module.

Using this Template in the QA Submission Component

Now, we’ll need to override all page templates using the Q&A Submission component to make sure it references this new partial. If you’re planning on using the Q&A module across all your pages, you’ll need to do this for each variation of page template - here, we’re modifying universal-standard, vertical-standard, vertical-grid, and vertical-map to override the script > qasubmission.hbs file.

image

Replace the contents of the file with the below:

Universal Pages


ANSWERS.addComponent('QASubmission', Object.assign({}, {

container: '.js-answersQASubmission',

template: `{{{read 'partials/customQA-universal' }}}`,

}, {{{ json componentSettings.QASubmission }}}));

Vertical Pages


ANSWERS.addComponent('QASubmission', Object.assign({}, {

container: '.js-answersQASubmission',

template: `{{{read 'partials/customQA-vertical' }}}`,

}, {{{ json componentSettings.QASubmission }}}));

This is just telling the template to use your new partials instead of the default template.

Now, you’ll be able to see clicks associated with these actions. Make sure to confirm by inspecting the Analytics events fired and looking in the platform to see if these clicks are being associated to the right organization & associated with the right event type.

Because this requires overriding the theme heavily, make sure to be careful for any theme upgrades you pursue in the future.

1 Like

@Amani you rock!! Thank you so much for your hard work on this it is working great.