# Alternative to request.headers\['user-agent'\]

**URL:** <https://community.hubspot.com/t/alternative-to-request-headers-user-agent/69519>\
**Category:** CMS Development\
**Created:** [November 17, 2022, 10:08pm UTC](https://community.hubspot.com/t/alternative-to-request-headers-user-agent/69519 "2022-11-17T22:08:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fernando\_Aguila](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/fernando_aguila/32/59655_2.png) [@Fernando\_Aguila](https://community.hubspot.com/u/Fernando_Aguila)\
**Post date:** [November 17, 2022, 10:08pm UTC](https://community.hubspot.com/t/alternative-to-request-headers-user-agent/69519/1 "2022-11-17T22:08:55Z")

</div>

I’m currently having problems with the request.headers[‘user-agent’] variable

There is another alternative in hubl to detect the client’s browser

it’s mandatory with hubl code

My code:  
Only works with preview pages, it worked fine a couple of days ago

{% set agent = request.headers[‘user-agent’]|lower|string %}

{% set isMobile = agent is string\_containing(“mobile”) ? true : false %}

 ![720026_1_resultado_esperado.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/3/f3ff188229c1cb37be78e4403d0fafd88e9dd2a6.jpeg)

 ![720026_2_resultado_obtenido.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/8/2876ff20647273bd3d505803f47c65f2946afd55.jpeg)

---

<div class="post-metadata">

**Author:** ![MBERARD](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mberard/32/61390_2.png) [@MBERARD](https://community.hubspot.com/u/MBERARD)\
**Post date:** [November 18, 2022, 9:26am UTC](https://community.hubspot.com/t/alternative-to-request-headers-user-agent/69519/2 "2022-11-18T09:26:53Z")

</div>

Hi, Fernando\_Aguila

Can you try this code :

```lia-code-sample
{% set agent = request.headers['user-agent']|lower|string %}
{% set isMobile = agent is string_containing "mobile" ? true : false %}

```

Kind regards,

Matthieu

[matthieu.berard@markentive.com](mailto:matthieu.berard@markentive.com)
