# E-commerce tracking using xAPI

* general repository: [EduPLEx API / User behavior tracker · GitLab](https://gitlab.com/eduplex-api/user-behavior-tracker)

Currently we are tracking **purchases.**

* **verb**: `http://activitystrea.ms/schema/1.0/purchase`
* **extension key:** `https://proto.eduplex.eu/xapi/extension/purchase`
* **extension data:**

  ```
  {
    "ecommerce": {
      "transaction": {
        "id": "X-XXXXXXXXXXX",
        "affiliation": "CT",
        "revenue": 0.1,
        "shipping": 0,
        "price_total": 0.1,
        "currency": "EUR"
      },
      "items": [
        {
          "id": "E-20",
          "name": "E-20",
          "brand": 4,
          "category": "Event-de",
          "price": 0,
          "quantity": 1,
          "price_unit": 0,
          "currency": "EUR"
        }
      ]
    }
  }
  ```

As every statement we are saving also data from the **offer** in the extension key `https://proto.eduplex.eu/xapi/extension/course_data`

## Example <a href="#e-commercetrackingusingxapi-example" id="e-commercetrackingusingxapi-example"></a>

<details>

<summary>Click here to watch an example of the statement</summary>

```
{
  "stored": "2023-08-08T13:22:17.764Z",
  "active": true,
  "completedForwardingQueue": [],
  "failedForwardingLog": [],
  "client": "62ed2d33caa1070008fbe17d",
  "lrs_id": "62ed2d33caa1070008fbe17c",
  "completedQueues": [],
  "activities": [
    "https://proto.eduplex.eu/xapi/object/types/purchase/4-1691500934526"
  ],
  "hash": "4dc2bbe650d6ee76575038b1eb23b91edfda9581",
  "agents": [
    "https://proto.eduplex.eu|3"
  ],
  "statement": {
    "authority": {
      "objectType": "Agent",
      "name": "EduPLEx Client",
      "mbox": "mailto:adrian@courseticket.com"
    },
    "stored": "2023-08-08T13:22:17.764Z",
    "context": {
      "extensions": {
        "https://proto.eduplex.eu/xapi/extension/device_token": "d95906a5-aec8-4234-9092-025c5c5b227d",
        "https://proto.eduplex.eu/xapi/extension/course_data": {
          "additionalType": 1,
          "coursePrerequisites": [],
          "teaches": [
            "Public test module",
            "Test module",
            "Text module",
            "h5p berries",
            "question setdddd",
            "xapi version test",
            "scorm versionf",
            "xapi hack",
            "xapi module partial content test",
            "Video partial test "
          ],
          "learningResourceType": 12,
          "hasCourseInstance": [
            {
              "@type": "CourseInstance",
              "offers": {
                "validFrom": "2023-08-08T13:22:09.663Z",
                "itemOffered": {
                  "@type": "Product",
                  "additionalProperty": [
                    {
                      "@type": "PropertyValue",
                      "name": "is_internal",
                      "value": false
                    },
                    {
                      "@type": "PropertyValue",
                      "name": "vat_effective",
                      "value": 0
                    },
                    {
                      "@type": "PropertyValue",
                      "name": "provider_is_topseller",
                      "value": false
                    },
                    {
                      "@type": "PropertyValue",
                      "name": "provider_is_verified",
                      "value": true
                    }
                  ]
                },
                "price": 0,
                "includesObject": {
                  "@type": "TypeAndQuantityNode",
                  "amountOfThisGood": 10,
                  "unitText": "modules"
                },
                "name": "Test1",
                "url": "https://proto.eduplex.eu/de/e/test1-20",
                "priceCurrency": "EUR",
                "priceSpecification": {
                  "@type": "PriceSpecification",
                  "maxPrice": 0,
                  "minPrice": 0,
                  "valueAddedTaxIncluded": "http://schema.org/True"
                },
                "@type": "Offer",
                "availability": "http://schema.org/InStock"
              },
              "instructor": [],
              "courseMode": "blended",
              "startDate": "2023-08-08T13:22:09.663Z",
              "endDate": "2024-08-08T13:22:09.662Z"
            }
          ],
          "keywords": [
            "Web-Designer/Web-Designerin",
            "mithilfe digitaler Technologien zusammenarbeiten",
            "IT-Projektmanager/IT-Projektmanagerin ",
            "Leiterplatten testen",
            "3D-Druckvorgang",
            "2D-CAD-Technik bei der Erstellung von Mustern für Schuhwerk einsetzen",
            "Prüfverfahren zur Tests der Wasserqualität durchführen",
            "Textiltestverfahren durchführen",
            "2D-Pläne lesen",
            "chemische Laboruntersuchungen an Metallen vornehmen"
          ],
          "name": "Test1",
          "timeRequired": "PT4H20M",
          "url": "https://proto.eduplex.eu/de/e/test1-20",
          "@context": "http://schema.org/",
          "educationalAlignment": [
            {
              "@type": "AlignmentObject",
              "alignmentType": "occupation",
              "targetUrl": "http://data.europa.eu/esco/occupation/c40a2919-48a9-40ea-b506-1f34f693496d"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/2b34a99f-9813-4c91-9509-b6b9b8c3132e"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "occupation",
              "targetUrl": "http://data.europa.eu/esco/occupation/8b6388a4-4904-471b-9331-d3b1211f5525"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/d1f435d2-e574-482c-8187-4a6c2214c683"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/2afb2b59-c9a3-4cf3-b1dd-1a2fad51e583"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/73c7d0d9-092f-4f6e-800a-5759f45a6fc6"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/e80f9e50-71ff-4bb7-8b7d-eb232685d17f"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/eb13f8c5-8300-4422-a51f-475a7edb09ef"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/dfce2aba-783e-4e17-9c17-e74aca505ec2"
            },
            {
              "@type": "AlignmentObject",
              "alignmentType": "skill",
              "targetUrl": "http://data.europa.eu/esco/skill/2b60c0cf-6ce6-4f04-9748-0e6d883673d8"
            }
          ],
          "provider": {
            "@id": "https://proto.eduplex.eu/de/u/demo",
            "@type": "Organization",
            "name": "demo",
            "url": "https://proto.eduplex.eu/de/u/demo",
            "image": "https://edupl.imgix.net/u/img/4-profile_pic.png?v=4&auto=compress&w=700&h=700&fit=crop"
          },
          "isAccessibleForFree": "http://schema.org/True",
          "@type": "Course",
          "image": "https://edupl.imgix.net/e/img/20-test1-event_pic.jpeg?v=2&auto=compress&w=1920&h=606&fit=crop",
          "@id": "https://proto.eduplex.eu/de/e/test1-20",
          "description": "Only a testing......",
          "inLanguage": "de"
        },
        "https://proto.eduplex.eu/xapi/extension/purchase": {
          "ecommerce": {
            "transaction": {
              "id": "4-1691500934526",
              "affiliation": "CT",
              "revenue": 0.1,
              "shipping": 0,
              "price_total": 0.1,
              "currency": "EUR"
            },
            "items": [
              {
                "id": "E-20",
                "name": "E-20",
                "brand": 4,
                "category": "Event-de",
                "price": 0,
                "quantity": 1,
                "price_unit": 0,
                "currency": "EUR"
              }
            ]
          }
        }
      }
    },
    "actor": {
      "account": {
        "homePage": "https://proto.eduplex.eu",
        "name": "3"
      },
      "objectType": "Agent"
    },
    "timestamp": "2023-08-08T13:22:17.764Z",
    "version": "1.0.0",
    "id": "2630b7af-62a4-464a-909f-9197548532bc",
    "verb": {
      "id": "http://activitystrea.ms/schema/1.0/purchase",
      "display": {
        "en-US": "purchased"
      }
    },
    "object": {
      "id": "https://proto.eduplex.eu/xapi/object/types/purchase/4-1691500934526",
      "definition": {
        "name": {
          "en-Us": "E-20"
        },
        "type": "https://proto.eduplex.eu/xapi/object/types/purchase/"
      },
      "objectType": "Activity"
    }
  },
  "hasGeneratedId": false,
  "deadForwardingQueue": [],
  "voided": false,
  "verbs": [
    "http://activitystrea.ms/schema/1.0/purchase"
  ],
  "processingQueues": [],
  "person": null,
  "timestamp": "2023-08-08T13:22:17.764Z",
  "relatedActivities": [
    "https://proto.eduplex.eu/xapi/object/types/purchase/4-1691500934526"
  ],
  "relatedAgents": [
    "https://proto.eduplex.eu|3",
    "mailto:adrian@courseticket.com"
  ],
  "organisation": "62ed1d89858c0c0008338e5c",
  "_id": "64d24189e13da3001b310384",
  "registrations": [],
  "pendingForwardingQueue": []
}
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eduplex.eu/user-behavior-tracker/e-commerce-tracking-using-xapi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
