Add custom xAPI statement when user clicks a link inside course presentation

Forums: 

Hello,
I would like to add an xAPI statement, called when a user clicks on a link in Course Presentation.
For example, such a structure:

{
  "actor": {
    "name": "Some User",
    "mbox": "mailto: someuser @ example.com",
    "objectType": "Agent"
  },
  "verb": {
    "id": "http:/ /id.tincanapi.com/verb/viewed",
    "display": {
      "en-US": "viewed"
    }
  },
  "object": {
    "id": "https:/ /external.url/some/path/file.php",
    "objectType": "Activity",
    "definition": {
      "extensions": {
        "http:/ /h5p.org/x-api/h5p-local-content-id": 69,
        "http:/ /example.com/link/type": "h5p-link"
      },
      "name": {
        "en-US": "Download your Manual"
      }
    }
  },
  "context": {
    "contextActivities": {
      "category": [
        {
          "id": "http:/ /h5p.org/libraries/H5P.CoursePresentation-1.21",
          "objectType": "Activity"
        }
      ]
    }
  }
}


Is that possible and how?

Content types: 
otacke's picture

Hi paulo!

You could either fork the content type and add extra event listeners directly, or you could add a custom script that listens for click/keydown evemts on the complete document, filters for events from anchor elements including a URL as a reference and trigger an xAPI in that case. The information that you want it to pass should be inside the H5PIntegration object that you should be able to access from your script directly.

Please see https://h5p.org/node/2692 for more information about customizing H5P using the alter_script hook.

Best,

Oliver