Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): improve documentation about purchases #195

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
![license](https://img.shields.io/github/license/Topsort/analytics.js)
![GitHub Repo stars](https://img.shields.io/github/stars/topsort/analytics.js?style=social)


# Topsort analytics.js

Topsort's JS analytics event library

Use this to send clicks and impressions to the Topsort API.
Expand Down Expand Up @@ -33,8 +33,22 @@ npm install @topsort/analytics.js --save

### Add markup to your products

Either mix quotes (single/double) or escape certain characters inside your values. In javascript:

```js
const newvalue = currentvalue.replace('"', """).replace("'", "'"); // etc.
```

Pass said values to your html:

```html
<div class="product" data-ts-product="<productId>" data-ts-resolved-bid="<resolvedBidId>">...</div>
<div
class="product"
data-ts-product="<productId>"
data-ts-resolved-bid="<resolvedBidId>"
>
...
</div>
```

Additionally, in case not all the container is clickable (i.e., does not produce an action or does not take you to the product page) or parts of it lead you to a non-related product page, make sure to use the `data-ts-clickable` attribute to indicate what portions of the product should count as a conversion.
Expand All @@ -49,7 +63,19 @@ Additionally, in case not all the container is clickable (i.e., does not produce
</div>
```

Finally, adding further information to purchases can be made by passing the `ts-data-items` JSON array:

```html
<div
data-ts-action="purchase"
data-ts-items='[{"product": "product-id-purchase-1", "quantity":1, "price": 2399}, {"product": "product-id-purchase-2", "quantity": 2, "price": 399}]'
>
My purchase
</div>
```

# E2E tests

Execute `npm run test:e2e`, at the end it will show you the url you need to visit to test the library.

Ideally you would check the library both in desktop and mobile browsers. For that you need to be connected to the same network.