Skip to main content

Send new visitors to your CRM

When someone signs up as a visitor of your world, you probably want them in your CRM, the minute they arrive, with their marketing consent up to date. This recipe builds that with n8n and HubSpot, in two small workflows:

  1. New visitor → contact: every new visitor becomes a HubSpot contact.
  2. Consent → contact: the contact's newsletter consent follows what the visitor decided in WorkAdventure, including when they change their mind later.

Using another CRM? Only the HubSpot nodes change, see Other CRMs.

Before you start​

  • A premium world where visitors can sign up (see below).
  • n8n with the WorkAdventure nodes installed and a WorkAdventure API credential, as explained in n8n. Your n8n must be reachable from the internet over HTTPS, which n8n Cloud is.
  • A HubSpot account. The free CRM is enough.

Make your guests register​

A visitor is someone who creates an account in your world by themselves: with the Register button of the login screen, or with one of its social login buttons. That's who this recipe sends to your CRM.

By default, though, anyone with the link to your world walks in as an anonymous user, without an account. WorkAdventure doesn't know their name or email, so nothing reaches your CRM. And as long as people can come in without an account, few will bother creating one.

To turn your guests into leads, make the account compulsory. In the admin dashboard, open Authentication in the left sidebar, turn on Mandatory authentication, keep Allow self-registration on, and click Save authentication settings.

Mandatory authentication and self-registration, both turned on

From now on, guests land on the login screen. They can't skip it: they sign in, or they register.

The login screen of the world: no way in without an account

See Managing access to your world for the other types of users.

Step 1: connect n8n to HubSpot​

n8n connects to HubSpot with a service key:

  1. In HubSpot, go to Development > Keys > Service Keys and click Create service key.
  2. Give it a name, click Add new scope and add crm.objects.contacts.read and crm.objects.contacts.write. Click Create.
  3. Open the key, click Show, then copy it.

Creating a service key in HubSpot

In n8n, create a HubSpot Service Key credential and paste the key.

"Unauthorized"?

When creating the credential, don't pick HubSpot API: it uses the API keys HubSpot has retired. Make sure to use HubSpot Service Key instead.

HubSpot needs a field to store the newsletter consent. In HubSpot, go to Settings > Data Management > Properties, click Create property and create:

  • Property label: WorkAdventure newsletter consent
  • Field type: Single checkbox

The "WorkAdventure newsletter consent" property, a single checkbox

Step 3: turn each new visitor into a contact​

  1. Create a workflow and add a WorkAdventure Trigger node. In Events, pick Visitor Registered.

    The WorkAdventure Trigger, on Visitor Registered

  2. Add a HubSpot node with the Create or update a contact action, and fill in:

    • Credential: your HubSpot Service Key credential
    • Email: {{ $json.data.email }}
    • Contact Properties: add First Name, {{ $json.data.name }}. WorkAdventure asks visitors for a single name.

    The HubSpot node creates or updates the contact from the email and the name of the visitor

    Instead of typing the expressions, you can drag the fields from the input panel on the left once you have tested the trigger.

Test it​

  1. In n8n, click Execute workflow. n8n registers a temporary webhook in your world and waits for an event for about two minutes.

  2. In the WorkAdventure admin, open Developers > Webhook settings, then the webhook whose URL contains webhook-test. Pick visitor.registered and click Test.

    Sending a test event from the webhook page

  3. Both nodes turn green in n8n.

    The workflow ran: the trigger received the event, HubSpot created the contact

  4. In HubSpot, a contact named Ana Ferreira, the sample visitor, shows up. HubSpot makes it a Lead. Delete it once you are done testing.

    Ana Ferreira, the sample visitor, in HubSpot

When it works, click Publish: from now on, every new visitor lands in HubSpot. Test events from WorkAdventure don't start a published workflow, so the sample visitor won't come back.

A new contact in your CRM is not yet someone you can email. To send newsletters, promotions or event announcements, you need their agreement. People who opted in actually read what you send, and they don't mark it as spam.

In many places, it is also the law. In the European Union and the United Kingdom, marketing emails to private individuals generally require their prior consent, and that consent must be freely given, specific and recorded (GDPR and ePrivacy rules). Canada's anti-spam law asks for consent too. Elsewhere, for instance under the US CAN-SPAM Act, an unsubscribe link may be enough, but asking costs nothing and works everywhere. This is not legal advice: check what applies to you.

Ask your visitors​

WorkAdventure only asks for consent for the purposes you declare. Without one, the sign-up form has no checkbox, and Consent Changed never fires.

In the admin dashboard, open Settings > Privacy / Compliance and turn on Send Newsletters and Promotional Materials: it is marked Consent required. The What your visitors will see panel shows the checkbox your visitors will get. Click Save personal data usage settings.

Declaring the newsletter purpose: the panel on the right previews the consent checkbox

The sign-up form now asks the question, with an unticked checkbox:

The sign-up form, with the consent checkbox

Visitors who registered before you declared the purpose are asked at their next login. Anyone can change their mind later from Privacy choices in the in-game menu, which sends a new Consent Changed event. See Configuring your privacy policy for the details.

note

Newsletters, events and surveys share a single checkbox ("Email me about…"), but each purpose gets its own Consent Changed event. That's why the workflow below filters on the purpose.

Sync the answer to HubSpot​

  1. Create a second workflow, with a WorkAdventure Trigger on Consent Changed. You receive one event per decision and purpose.

  2. Add a Filter node that keeps the newsletter decisions: {{ $json.data.purpose }} is equal to newsletter.

    The Filter node keeps the decisions about the newsletter

    The other purposes are events, feedback_survey, third_party, community and custom, depending on what your privacy policy asks for. Duplicate the workflow for each one you track.

  3. Add a HubSpot node, Create or update a contact again:

    • Email: {{ $json.data.email }}
    • Contact Properties: add Custom Properties, pick WorkAdventure newsletter consent and set the value to {{ $json.data.granted === true }}

    The HubSpot node sets the consent property from the decision

    granted is true when the person agreed, false when they refused or withdrew their consent, and null when an administrator took the decision off the record. The expression turns the last two into "no".

  4. Test it like the first workflow, sending consent.changed instead.

    The consent workflow ran

    On Ana Ferreira's contact, Actions > View all properties now shows the consent:

    WorkAdventure newsletter consent: Yes

  5. Click Publish.

You can now filter your HubSpot lists and email campaigns on WorkAdventure newsletter consent.

Other CRMs​

The WorkAdventure side stays the same. Replace the HubSpot nodes:

  • Pipedrive: its node has no create or update. Search the person by email first, then Update or Create them, with an If node in between.
  • Other CRMs: n8n has nodes for most of them. Use their create-or-update action (sometimes called upsert) on the email when they have one.

You can also use Zapier instead of n8n. The WorkAdventure triggers are the same, but the CRM actions differ. In Zapier: use the New Visitor and New Consent Decision triggers to start the zap.