Rich-text Reply
Highlighted

custom audiences

hal2018 2w ago
Accepted Solution

custom audiences

Hi,

I'm trying to set up a audience for devices. I don't want my experience to display on iPhone SE. So created a custom javascript audience that displays over a certain screen size however when doing this my experience no longer works on iPhone. Does anyone know how to create audiences for specific device types. 

 

Thanks!

 

Screen Shot 2018-05-14 at 11.33.15.png
Level 2

Re: custom audiences

Hi Hal2018,

You would have to check for the user agent of iPhone SE.
I googled and found the link below which has a list of user agents for iPhone SE.

https://developers.whatismybrowser.com/useragents/explore/operating_platform/iphone-se/

You can then use window.navigator.userAgent.match within the javascript audience condition to look for key attributes of the iPhone SE user agent.

Here is an example I created below which uses regex expressions to look for combinations of user agents and only returns TRUE if it does not find these combinations in the user agent of the visitors device.

(window.navigator.userAgent.match(".*((?=.*FBAV\/144).*(?=.*iPhone) | (?=.*FBAV\/157).*(?=.*iPhone)).*") == null)

In this example I have only included two groups of combinations separated by a pipeline |

1ST GROUP:
(?=.*FBAV\/144).*(?=.*iPhone)

This is checking if user agent contains the attributes FBAV/144 AND iPhone.
If a user had the user agent below, they would not pass this group.
Note: this group would cover 9 of the user agents in the link above that have FBAV/144

Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 [FBAN/FBIOS;FBAV/144.0.0.55.89;FBBV/74129168;FBDV/iPhone8,4;FBMD/iPhone;FBSN/iOS;FBSV/10.3.3;FBSS/2;FBCR/Koodo;FBID/phone;FBLC/en_US;FBOP/5;FBRV/74129168]

2ND GROUP:
(?=.*FBAV\/157).*(?=.*iPhone)

This is checking if user agent contains the attributes FBAV/157 AND iPhone.
If a user had the user agent below, they would not pass this group.
Note: this group would cover 8 of the user agents in the list

Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_2 like Mac OS X) AppleWebKit/604.4.7 (KHTML, like Gecko) Mobile/15C202 [FBAN/FBIOS;FBAV/157.0.0.42.96;FBBV/90008621;FBDV/iPhone8,4;FBMD/iPhone;FBSN/iOS;FBSV/11.2.2;FBSS/2;FBCR/fido;FBID/phone;FBLC/en_US;FBOP/5;FBRV/90421205]

You can continue building the groups until it covers all the user agents.
Unfortunately there doesn't seem to be a unique key attribute in the user agent for iPhone SE which is why we have to look for the FBAV number in each group.

Alternatively you might be able to do this by using navigator.userAgent.indexOf
example:

window.navigator.userAgent.indexOf("FBAV/157") == -1 && window.navigator.userAgent.indexOf("FBAV/144") == -1

Regards
Optimizely