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:
data-nameordata-email: used as the visitor's name in the dashboard until they start a chat.data-avatar: anhttps://image address, shown as the visitor's photo instead of a letter.
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 photo and name, with the other values as small chips under each visitor.
- Chat details: a "Custom data" section next to the chat. Hover a value to see all of it, click to copy.
- Chat list and header: the visitor's photo.
data- value as a chip under the visitor.
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
- Up to 20 values per visitor, each up to 300 characters. A new value for the same name replaces the old one.
- Names may use letters, numbers,
-and_. - Never put passwords or keys in the embed code. Anyone who views the page can read it. Names that look like secrets (
pass,pwd,secret,token,key,auth,session,cookie) are never sent or saved, and the browser console shows a warning.