<commit_before>.. _advanced_features/passing_custom_data:
.. include:: /partials/common.rst

Pass Custom User Data
=====================

The ``custom_properties`` variable allows you to pass any custom data
to Talkable as a collection of Key-Value pairs.
Those can be used for various segmentation purposes, since join criteria and incentive criteria are capable of using the ones in conditions.

All data associated with ``custom_properties`` is available for use
across all Campaign Views.


How to set
==========

**Initialization script**

Add the ``custom_properties`` collection in the ``register_affiliate`` call of the Initialization script.

.. code-block:: javascript

  _talkableq.push(['register_affiliate', {
    custom_properties: {
      person_occupation: 'marketing',
      eye_color: 'brown'
    }
  }]);

**Post-purchase script**

Add the ``custom_properties`` collection to the data passed in the ``register_purchase`` call. It should be nested the same as ``purchase`` collection.

.. code-block:: javascript

  var _talkable_data = {
    purchase: {
      order_number: '',
      subtotal: '',
    },
    custom_properties: {
      person_occupation: 'marketing',
      eye_color: 'brown'
    }
  };
  _talkableq.push(['register_purchase', _talkable_data]);


.. note::

    The values you pass in the ``custom_properties`` have to be JSON Key-Value pairs themselves,
    meaning that complex nested data structures can not be passed through.

How to use
==========

To access ``custom_properties`` in Talkable, use:

.. code-block:: liquid

   {{ advocate_custom_properties }}
   {{ friend_custom_properties }}
<commit_msg>Fix headings in custom properties (#183)<commit_after>.. _advanced_features/passing_custom_data:
.. include:: /partials/common.rst

Pass Custom User Data
=====================

The ``custom_properties`` variable allows you to pass any custom data
to Talkable as a collection of Key-Value pairs.
Those can be used for various segmentation purposes, since join criteria and incentive criteria are capable of using the ones in conditions.

All data associated with ``custom_properties`` is available for use
across all Campaign Views.

.. raw:: html

   <h2>How to set</h2>

**Initialization script**

Add the ``custom_properties`` collection in the ``register_affiliate`` call of the Initialization script.

.. code-block:: javascript

  _talkableq.push(['register_affiliate', {
    custom_properties: {
      person_occupation: 'marketing',
      eye_color: 'brown'
    }
  }]);

**Post-purchase script**

Add the ``custom_properties`` collection to the data passed in the ``register_purchase`` call. It should be nested the same as ``purchase`` collection.

.. code-block:: javascript

  var _talkable_data = {
    purchase: {
      order_number: '',
      subtotal: '',
    },
    custom_properties: {
      person_occupation: 'marketing',
      eye_color: 'brown'
    }
  };
  _talkableq.push(['register_purchase', _talkable_data]);


.. note::

    The values you pass in the ``custom_properties`` have to be JSON Key-Value pairs themselves,
    meaning that complex nested data structures can not be passed through.

.. raw:: html

   <h2>How to use</h2>

To access ``custom_properties`` in Talkable, use:

.. code-block:: liquid

   {{ advocate_custom_properties }}
   {{ friend_custom_properties }}

{'fraction_non_alphanumeric': 0.11724343675417662, 'fraction_numerical': 0.002088305489260143, 'mean_word_length': 4.026986506746627, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '927796', 'n_tokens_mistral': 965, 'n_tokens_neox': 919, 'n_words': 333}