1.0.4 • Published 5 years ago

@convious/convious-analytics v1.0.4

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Convious Analytics

This is a JavaScript library, similar to Google Analytics, that should be added to your website. It allows registering events that are needed for pricing API to function.

Installing

By adding a script tag

<script type="text/javascript" src="https://resources.convious.com/analytics.js"></script>

You can add our script to the head element of your website. In order to function properly, this script must be present on every page.

Using NPM

npm install @convious/convious-analytics

You can also bundle the script in your JavaScript using npm/yarn.

Initializing

If installed by adding a script tag:

conviousPricing.init(accountId, cookieId);

If installed using npm/yarn:

import * as conviousPricing from '@convious/convious-analytics'
conviousPricing.init(accountId, cookieId);

In order to function, the library must first be initialized with the ID of your Convious account and the cookie ID of the user.

Parameters:

NameTypeRequiredDescription
accountIdstringyesAccount ID of your Convious account
cookieIdstringyesCookie ID of the user browsing the website

Sending events

Once initialized, events can be sent using the library.

Page viewed event

conviousPricing.logPageView(refererUrl, currentUrl);

This event notifies that the user has visited a page in the website. In conventional websites the page visits are logged automatically and this does not need to be called directly. However, if your website is a single-page application, it must be called on each application route change.

Parameters:

NameTypeRequiredDescription
refererUrlstringyesThe URL the user is coming from
currentUrlstringyesThe URL the user has arrived in

User entered checkout event

conviousPricing.logUserEnteredCheckout();

This event notifies that the user has opened a page where he can buy products or opened a html widget within a page that allows him to buy products.

User selected date event

conviousPricing.logUserSelectedDate();

This event notifies that the user has selected event date when buying a product.

User viewed products event

conviousPricing.logUserViewedProducts();

This event notifies that the user has seen a list of available products he can buy.

User viewed prices event

conviousPricing.logUserViewedPrices();

This event notifies that the user has seen prices for the products.

User added an item to cart event

conviousPricing.logUserAddedAnItemToCart();

This event notifies that the user has added a product to cart.

Order created event

conviousPricing.logOrderCreated({
    orderId: '<order_id>',
    items: [{
        productId: '<product_id>',
        amount: 2,
        price: 12.99,
        eventDate: new Date(2018, 4, 1),
        location: 'Almere',
    }, {
        productId: '<product_id>',
        amount: 1,
        price: 11.99,
        eventDate: new Date(2018, 4, 1),
        location: 'Almere',
    }]
});

This event notifies that the user has created an order.

Parameters:

NameTypeRequiredDescription
orderIdstringyesThe ID of the order being made
items.productIdstringyesThe ID of a product in the order
items.amountnumberyesThe number of items of a product in the order
items.pricenumberyesThe item price of a product in the order
items.eventDateDatenoThe date when the event is taking place in case the product is time based
items.locationstringnoThe location id where the product is being sold (in case of multiple venues at different locations)

Transaction event

conviousPricing.logTransaction(orderId, totalAmount);

This event notifies that the user has made a purchase.

Parameters:

NameTypeRequiredDescription
orderIdstringyesThe ID of the order that was paid
totalAmountnumberyesThe total sum of the order
1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago