Javascript API Integration


This integration with the Interacty API allows you to dramatically expand the functionality of your projects by incorporating new features. You have the ability to log any events happening in the Interacty app like game_start, game end, select trivia option, lead form submit and others.

With Javascript API, you can do:

  • track users across different projects since we support “clientId”.

  • send custom google analytics events

  • log detailed trivia/personality answers

  • track lead form data

  • make your funnel analytics more granular

  • pass all this information to your CRM

  • and many other

Javascript API integration is available for all tariff plans.

It’s easy to start if you have a project embedded on your site. Just add a global function onInteractyEvent.

<html>
   <body>
       <div class="remix-app" hash="cec2cf3137189f7d">
           <script src="https://p.interacty.me/l.js" async></script>
       </div>
       <script type="text/javascript">
           function onInteractyEvent(event, payload) {
               console.log(event, payload)
           }
       </script>
   </body>
</html>

If you don’t embed project on your site and want to use Javascript API please reach us at info@interacty.me

Now we are going to show an event chain example when users go through the project. Let’s take a look at the Trivia quiz.


Trivia workflow example

User opens a link with the project, project loads. A few events happen:

event: IFRAME_INIT
payload: {}

event: IFRAME_ONLOAD
payload: {}

event: REMIX_INIT
payload: {}

event: REMIX_ONLOAD
payload: {}

Then the user clicks on the “Start” button.

event: ACTION
payload:
   actionTypeName: "QUIZ_STARTED"
   blockId: "4qgynl"
   clientId: "LFWG37VVmOEmkC57"
   fields:
      gameId: "mqRjSWHr8cBFLwWU3ONoo"
   projectId: 188343527
   sessionId: 205487015

User selects an answer option.

event: ACTION
payload:
   actionTypeName: "QUIZ_ANSWER"
   blockId: "4qgynl"
   clientId: "LFWG37VVmOEmkC57"
   fields:
      answerId: "jLG3-FIZ"
      gameId: "mqRjSWHr8cBFLwWU3ONoo"
      questionId: "ivaN4AOR"
   projectId: 188343527
   sessionId: 205487015

All questions answered, two events follow.

event: ACTION
payload:
   actionTypeName: "QUIZ_COMPLETED"
   blockId: "4qgynl"
   clientId: "LFWG37VVmOEmkC57"
   fields:
      gameId: "mqRjSWHr8cBFLwWU3ONoo"
   projectId: 188343527
   sessionId: 205487015


event: ACTION
payload:
   actionTypeName: "QUIZ_RESULT"
   blockId: "4qgynl"
   clientId: "LFWG37VVmOEmkC57"
   fields:
      gameId: "mqRjSWHr8cBFLwWU3ONoo"
      resultId: "R4_aPcUX"
   projectId: 188343527
   sessionId: 205487015

This project contains a Lead Form. When the user fills the form it the event triggers.

event: ACTION
payload:
   actionTypeName: "COMMON_LEAD_FORM"
   blockId: "4qgynl"
   clientId: "LFWG37VVmOEmkC57"
   fields:
      company: ""
      companyURL: ""
      email: "alex@example.org"
      firstName: "Alex"
      lastName: ""
      phoneNumber: "+133345678890"
   projectId: 188343527
   sessionId: 205487015

Parameters

  • actionTypeName: (value example: "QUIZ_RESULT") - event name, it depends on the game type. For example, for memory game it has the “MEMORY_RESUL” name etc.

  • blockId: (value example: "4qgynl") - block id in the project. Remember, that your project may have a few blocks on one page (let’s say you may add 2 quizzes, fortune wheel, youtube video, an image = 5 blocks!). So you have the ability to track events for a specific block.

  • clientId: (value example: "LFWG37VVmOEmkC57") global user browser id. It is constant across Interacty projects unless the user clears cookies or uses a new device/browser.

  • projectId: (value example 188343527) project id you created on Interacty. This is a constant.

  • sessionId: (value example: 205487015) when a user opens a browser page with the Interacty project a session is created. After a tab refresh a new session is created.

  • gameId: (value example: "mqRjSWHr8cBFLwWU3ONoo") a game attempt id. If a user restarts a game/quiz even without browser page refresh a new game starts with a new gameId.


App integration notes

This Javascript API was originally designed for embedded Interacty apps. But if you’re interested in using them in application-by-link (https://interacty.me/projects/cec2cf3137189f7d) or you need to post this data to your endpoint don’t hesitate to reach out info@interacty.me.


Was this article helpful?