We want to embed G2 into our Vanilla community so users can complete a review while visiting the site. Has anyone had success creating custom code to allow this?
Hey there! I've not used G2 before, but I skimmed over some of their available documentation on the 'Review Us' buttons (https://documentation.g2.com/docs/review-collection-widgets) and I think Vanilla can handle putting a survey just about anywhere that you need. Jump to the Appearance tab and edit the layout of the page that you want this to appear on (since you're describing a 'Review' type of survey, I imagine it at the bottom of the homepage). Add a Custom HTML widget to place that you're wanting to place it:
G2 will supply you a code snippet of the Review button that you create in their platform. In the HTML tab of the Custom HTML widget, you'll put the code for the CTA button you designed on G2 (the 'step 1' bit from the documentation):
In the CSS tab, we probably don’t need anything because G2 generates all the button styling. You could still use this tab for any Vanilla-side spacing or positioning around the CTA. In the Javascript tab, we need adapt their Step 2 supporting code. One thing we’d want to test is whether G2’s script can initialize its CTA inside Vanilla’s Custom HTML widget (since Vanilla widgets use Shadow DOM). If the G2 script expects its placeholder to exist in the normal page DOM, it may need a small adjustment.
G2 prefers this code in the page <head>, but explicitly says that when a CMS doesn’t provide head access, that it can be placed with the CTA instead.
<head>
Quick note about <script> tags here: Our Custom HTML widgets in the layout editor provide separate HTML and JavaScript tabs, so you may need to doctor the G2 script a little bit rather than just pasted in as-is. If G2 provides inline JavaScript wrapped in <script>...</script>, remove the <script> tags and place the JavaScript itself in the JavaScript tab. If the snippet instead contains an external <script src="...">, that script may need to be loaded programmatically from the JavaScript tab rather than simply removing the tags.
<script>...</script>
<script>
<script src="...">
Last big thing to remember is to make sure you allow the G2.com domain in your community's security settings (/dashboard/settings/security). Add www.G2.com to the Trusted Domains and Content Security Domains section.
/dashboard/settings/security
www.G2.com
I hope this helps! Just from reading over the G2 docs on this, I feel like this is very do-able in Vanilla (with only a little bit of fiddling of the copy-paste code G2 provides you).
Hi @tipton2023 - thanks for your question!
We've had a few customers add surveys to their communities before:
@saramaloney @annayardley could either of you provide some more details on how you integrated a survey into your communities?
We used Sprig for it and had our devs add it to our site upon a user's first login. It doesn't appear again unless they clear their cache.