-1

First post on here I have a very specific question, I'm working with Freewheel (Video Ad Serving Platform)and needed a way to send back to Freewheel the environment type whether desktop or Mobile or Tablet so it can filter by these 3 environments.

I want to do use the user agent detection to do this but not sure how to start it any help with this will be very useful

Thanks in advance Doyin

  • What you tried so far? Getting the user agent with Javascript is [as simple as these W3C schools docs explain.](https://www.w3schools.com/jsref/prop_nav_useragent.asp). Also look into specific JS libraries designed for detecting device information, which can grab all sorts of info about the browser. Also remember user agents can be easily spoofed, so don't use this for security purposes! – samiles Feb 24 '17 at 10:19
  • 1
    @samiles — Don't confuse the W3C (who are a standards organisation) with W3Schools (who are a terrible tutorial mill) – Quentin Feb 24 '17 at 10:22
  • @Quentin Yeah yeah we all know that, but in that link a single line of code is obvious, what more could they have done? Feel free to add the link to your preferred webpage with that identical line of code on it. – samiles Feb 24 '17 at 10:23
  • 2
    Arguably this is *too broad* a question. The short version is: look at the user agent string. The long version would include a long long list of possible user agent matching regexes and what platform that indicates and some handwaving about what is "mobile" and what isn't, which is never going to be complete and impossible to maintain as a Q&A here. If you need to be comprehensive, best use some library which is maintaining such a list. – deceze Feb 24 '17 at 10:25
  • 1
    @samiles I think the issue Quentin takes here is "W3C schools." It's just "w3schools" (**no "C"**), in no way affiliated with the W3C. – deceze Feb 24 '17 at 10:27

1 Answers1

-2

You can get User-Agent from server side. All User-Agent have a Common format for web browsers.

User-Agent: Mozilla/<version> (<system-information>) <platform> (<platform-details>) <extensions>

You can find more information from hear. So you can get <platform>/Environments from User-Agent.

Emran
  • 138
  • 1
  • 11
  • Sorry will add more information I basically want to take the information I get from the useragent and register whether its a Desktop, Mobile or Tablet. Haven't started anything yet just wanted to know if the code is already there that I take and build on if needed? – Doyin Atunrase Feb 24 '17 at 10:51
  • So basically developing a function that will spit out the environment type the user is using so instead of saying the exact mobile phone type it will just say environment type = Mobile – Doyin Atunrase Feb 24 '17 at 10:56
  • Ok. you want a function, which get user agent and return environment type? Which server side language are you use? – Emran Feb 24 '17 at 10:58
  • I'm open to suggestions but I really would like to keep this using the user-agent funtions with js – Doyin Atunrase Feb 24 '17 at 11:03
  • Now I am totally confused about you question. If you want to know which type of environment is it from JS, you can see this. http://stackoverflow.com/questions/11381673/detecting-a-mobile-browser – Emran Feb 24 '17 at 11:09
  • Thanks this actually helps sorry for consuing – Doyin Atunrase Feb 24 '17 at 11:17
  • You are welcome. If its help you then i am happy. :) – Emran Feb 24 '17 at 11:20
  • Actually writing the code was the issue so needed an example – Doyin Atunrase Feb 24 '17 at 11:23