I answered the question that the other user linked but for completeness sake here is an example that suits your use case.
You can use the content_for_header liquid object details to detect admin inside liquid code blocks.
The following example snippet will only include the example div for admin users.
{% if content_for_header contains 'adminBar' %}
Admin Detected
{% endif %}
The code does not get included for regular visitors, just for admins.