ZOCIALDMOpen dashboard

‹ All guides

Show who your visitors are

Add your own details to the chat embed code, like the customer's name, email, plan or photo. Your team sees them on the Visitors page and next to every chat, even before the visitor types a word.

The basics

Every data- attribute on the embed code, except data-project, is sent with each page view and saved on that visitor. Name them whatever you like.

<script src="https://zocialdm.com/widget.js" data-project="YOUR_KEY"
  data-name="Somchai" data-email="somchai@example.com"
  data-plan="pro" data-user-id="1042"
  data-avatar="https://your-site.com/avatars/1042.jpg" async></script>

Three names are special:

Everything else appears as it is, with a readable label: data-user-id shows as "User ID", data-plan as "Plan".

Where you see it

Visitors page: the visitor's photo and email, with chips for Name, Email, Plan, User ID and Orders
Visitors page: every data- value as a chip under the visitor.
A chat with the visitor's photo in the header and a Custom data section listing Name, Email, Plan, User ID and Orders
Chat details: data-avatar becomes the photo, the rest is listed under Custom data.

Fill it in for the signed-in customer

The values usually come from whoever is logged in to your site. Print them into the embed code on the server, or add the script with JavaScript. Leave them out for guests.

WordPress (PHP)

Haven't added the chat yet? Start with the WordPress + WooCommerce guide.

Add this to your theme's functions.php, or to a WPCode snippet with type PHP Snippet and Run Everywhere. Then remove the plain embed code, or the widget loads twice.

add_action('wp_footer', function () {
  $attrs = [
    'src'          => 'https://zocialdm.com/widget.js',
    'async'        => true,
    'data-project' => 'YOUR_KEY',
  ];
  $user = wp_get_current_user();
  if ($user->exists()) {
    $attrs['data-name']    = $user->display_name;
    $attrs['data-email']   = $user->user_email;
    $attrs['data-user-id'] = $user->ID;
    $attrs['data-avatar']  = get_avatar_url($user->ID);
  }
  wp_print_script_tag($attrs); // escapes every value for you
});

Prefer a plain <script> tag? Put this in your theme's footer.php just before </body>, in place of the plain embed code:

<?php $user = wp_get_current_user(); ?>
<script src="https://zocialdm.com/widget.js" data-project="YOUR_KEY"
<?php if ($user->exists()) : ?>
  data-name="<?= esc_attr($user->display_name) ?>"
  data-email="<?= esc_attr($user->user_email) ?>"
  data-user-id="<?= esc_attr($user->ID) ?>"
  data-avatar="<?= esc_url(get_avatar_url($user->ID)) ?>"
<?php endif; ?>
  async></script>

A theme update can overwrite footer.php; use a child theme, or the functions.php version above.

Shopify (Liquid)

Haven't added the chat yet? Start with the Shopify guide.

In Online Store › Themes › Edit code › layout/theme.liquid, replace the embed code before </body> with:

<script src="https://zocialdm.com/widget.js" data-project="YOUR_KEY"
{% if customer %}
  data-name="{{ customer.name | escape }}"
  data-email="{{ customer.email | escape }}"
  data-orders="{{ customer.orders_count }}"
  data-spent="{{ customer.total_spent | money_without_currency }}"
{% endif %}
  async></script>

JavaScript apps (React, Next.js, Vue …)

Add the script once you know who the user is, for example right after sign-in:

const s = document.createElement('script');
s.src = 'https://zocialdm.com/widget.js';
s.async = true;
s.dataset.project = 'YOUR_KEY';
s.dataset.name = user.name;
s.dataset.email = user.email;
s.dataset.plan = user.plan;
s.dataset.avatar = user.photoUrl; // https only
document.body.appendChild(s);

The widget reads the values when it loads. If they change later on the same page, they're picked up on the next full page load.

Rules and limits

These values come from the visitor's browser, so a visitor could change them. Use them to see who you are talking to, not as proof of identity. They aren't used as the chat email, so Claude never looks up orders based on them.