# Sending data (browser)

The eCommerce server generates JavaScript code which is returned to the end customer's browser. In effect the end customer browser sends the data to edrone servers.


edrone_2_0.js - external library provided by edrone - initial code that should be included in head section.

https://d3bo67muzbfgtl.cloudfront.net/edrone_2_0.js - it should be initialized once using the following script

_edrone.init() - function that is used to send data to edrone - it is automatically initialized after event "window.onload".

# OTHER


Expected result for "other" action for logged in customer

other_with_logged_customer


Expected result for "other" action for not logged in customer

other_without_logged_customer

# HOMEPAGE VIEW


Expected result for "homepage_view" action for not logged in customer

homepage_view_without_logged_customer

<script type="text/javascript">
       window._edrone = window._edrone || {};
       _edrone.action_type = 'homepage_view'; //override the default "other" value 
</script>

# PRODUCT VIEW

If you already have initial script include in your head section, the next step is to implement product_view action. That should be implemented in the end of the body section:

<script type="text/javascript">
       window._edrone = window._edrone || {};
       _edrone.product_skus = 'MAK03035';
       _edrone.product_ids = '3434';
       _edrone.product_titles = 'SANTI-DONNA'; // use url_encode
       _edrone.product_images = 'https://x.z..com/media/s/x/cache/3/image/df/3/u/3u1a6597--1200q100.jpg'; // use url_encode 
       _edrone.product_urls = 'https://x.z..com/3u1a6597--1200q100'; // use url_encode 
       _edrone.product_availability = 1;
       _edrone.product_category_ids = "12~24~36" // use "~" sign to separate values from each other 
       _edrone.product_category_names = "Buty~Buty damskie~Szpilki" // use "~" sign to separate values from each other and url_encode on single value
       _edrone.action_type = 'product_view';
</script>


Expected result for "product_view" action for logged in customer

product_view

# CATEGORY VIEW

The next step is to implement category_view action. That should be implemented in the end of the body section:

<script type="text/javascript">
       window._edrone = window._edrone || {};
       _edrone.product_category_ids = "12~24~36" // use "~" sign to separate values from each other 
       _edrone.product_category_names = "Buty~Buty damskie~Szpilki" // use "~" sign to separate values from each other and url_encode on single value
       _edrone.action_type = 'category_view';
</script>


Expected result for "category_view" action for logged in customer

category_view

# ADD TO CART

The next step is to implement the add_to_cart action. It also should be implemented in the end of body section, but if the add_to_cart button is on the same page as product you only have to change action_type to add_to_cart:

<script type="text/javascript">
       window._edrone = window._edrone || {};
       let addToCartButton = document.querySelector("#addToCartButton")
       if (addToCartButton) {
         addToCartButton.addEventListener('click', () => {
           _edrone.action_type = "add_to_cart"
           _edrone.init()
         })
       }
</script>


The expected result for the "add_to_cart" action for a logged in customer

product_view

What if your add to cart button is included in some product list(home page, category page)?

<script type="text/javascript">
       window._edrone = window._edrone || {};
       let addToCartButtonList = document.querySelectorAll(".addToCartButton")
       addToCartButtonList.forEach((button) => {
         if (button) {
           button.addEventListener('click', () => {
           _edrone.product_ids = button.getAttribute('product_ids')
           _edrone.product_skus = button.getAttribute('product_skus')
           _edrone.product_titles = button.getAttribute('product_titles')
           _edrone.product_images = button.getAttribute('product_images')
           _edrone.product_urls = button.getAttribute('product_urls')
           _edrone.product_category_ids = button.getAttribute('product_category_ids')
           _edrone.product_category_names = button.getAttribute('product_category_names')
           _edrone.action_type = "add_to_cart"
           _edrone.init()
         })
         }
       })
</script>

# ORDER


The next step is to implement order action. Thats also should be implemented on the "success page" at the end of body section.
<script type="text/javascript">
       window._edrone = window._edrone || {};
       _edrone.action_type = 'order';
       _edrone.email = 'john.doe@edrone.me';
       _edrone.user_id = '1234';
       _edrone.first_name = 'John';
       _edrone.last_name = 'Doe';
       _edrone.subscriber_status = '1';
       _edrone.product_skus = 'NL1975286|NL2075286'; // use "|" sign to separate products from each other
       _edrone.product_ids = '12|13'; // use "|" sign to separate products from each other
       _edrone.product_titles = 'Sorel Women shoes Glacy|Sorel Women shoes Glacy Explorer Shortie'; // use "|" sign to separate products from each other and use url_encode
       _edrone.product_images = 'https://demo-store.edrone.me/img/p/4/5/45-large_default.jpg|https://demo-store.edrone.me/img/p/4/7/47.jpg'; // use "|" sign to separate products from each other and use url_encode
       _edrone.product_urls = 'https://demo-store.edrone.me/index.php?id_product=12&controller=product|https://demo-store.edrone.me/index.php?id_product=13&controller=product'; // use "|" sign to separate products from each other and use url_encode
       _edrone.product_category_ids = '2~3~4|2~3~4'; // use "|" sign to separate products from each other and "~" to separate values connected to product from each other and use url_encode
       _edrone.product_category_names = 'Main~Shoes~Women shoes|Main~Shoes~Women shoes'; // use "|" sign to separate products from each other and "~" to separate values connected to product from each other and use url_encode
       _edrone.product_counts = '1|3'; // use "|" sign to separate products from each other
       _edrone.order_id = '4321';
       _edrone.country = 'UK';
       _edrone.city = 'London';
       _edrone.base_currency = 'GBP';
       _edrone.order_currency = 'GBP';
       _edrone.base_payment_value = '671.50';
       _edrone.order_payment_value = '671.50';
</script>

# SUBSCRIBE


How to integrate your newsletter form with edrone:
<script>
  window._edrone = window._edrone || {};
  let newsletterForm = document.querySelector('#newsletterForm')
  if (newsletterForm) {
    newsletterForm.addEventListener('submit', () => {
      _edrone.customer_tags = 'Footer'; // You can use different tags for different forms.
      _edrone.email = newsletter.querySelector('input[type="email"]').value;
      _edrone.first_name = newsletter.querySelector('input[type="name"]').value;
      _edrone.action_type = 'subscribe';
      _edrone.init();
    })
  }
</script>


# Fields with multiple values

Certain event types may require multiple values in the trace field. For example, when an order event occurs the customer might have purchased multiple items.

In order to specify multiple values in a field separate them by pipe character (|)

Example

_edrone.product_skus = 'MAK03035|FE01041';

The following fields allow multiple values:
  • product_ids
  • product_titles
  • product_images
  • product_skus
  • product_urls
  • product_category_ids
  • product_category_names
  • customer_tags
  • product_counts
  • product_brand_ids
  • product_brand_names

# Product with multiple categories

A single product may belong to multiple categories (product_category_ids I product_category_names). In such case each category should be separated by a ~ character.

Example

 _edrone.product_category_ids = '12~24~36';
 _edrone.product_category_names = 'Buty~Buty damskie~Szpilki';

Character encoding Any special characters (e.g. ",',<,>,&) should be encoded using url_encode function.