Menu
Feedback
Start here
Tutorials
Developer portal

Known Issues
Support Rules
Troubleshooting

Frequently Asked Questions
Announcements
Tutorials
Tutorials
Explore in-depth tutorials for operating your VTEX store.
Tutorials
Storefront
Layout
Welcome message control
Welcome message control

The control <vtex.cmc:welcomeMessage/> renders a welcome message, which should be used in the store topbar.

See an example in the image below.

{"base64":"  ","img":{"width":331,"height":41,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":2199,"url":"https://raw.githubusercontent.com/vtexdocs/help-center-content/refs/heads/main/docs/en/tutorials/Storefront/Layout/welcome-message-control_1.png"}}

HTML code rendered

Here is an example of the code rendered by this control:


<div class="welcome col-xs-5">
<script>
$(document).ready(function () {
vtexid.setScope('1acde8b8-c134-45ca-bda6-8496f39d6734');
vtexid.setScopeName('lojadobreno');
$('body').on('click', '#login', function () {
vtexid.start(
{
returnUrl: '/produto-teste/p',
userEmail: '',
locale: 'en-US',
forceReload: false
});
});
});
</script>
<div class="ajax-content-loader" rel="/no-cache/user/welcome">
<p class="welcome">
Bem-vindo!
<em><a id="login">Já é cadastrado?
</a></em>
</p>
</div>
</div>

Login trigger script

Note that the control renders an HTML code with the welcome message and also a script.

This script is triggered when the user clicks on the element with ID "login", which by default comes with the message "Já é cadastrado?" ("Already registered?"), and is responsible for taking the user to the login screen.

The script rendered by the control also creates a cookie responsible for informing the store that the user is logged in.

Other VTEX services use the same cookie (for example, product reviews), so they don't need to ask the user to sign in again.

See in the example script above that the method which creates this cookie is vtexid.setScope().

Still following the example above, the cookie created would be the following: UserGUID=1acde8b8-c134-45ca-bda6-8496f39d6734

Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor
Photo of the contributor
+ 2 contributors
On this page
Still got questions?
Ask the community
Find solutions and share ideas in the VTEX community.
Join our community
Request support from VTEX
For personalized assistance, contact our experts.
Open a support ticket
GithubDeveloper portalCommunityFeedback