First Question:
There are two images that needed to be rendered in Salesforce Marketing Cloud based on where they're being viewed from (Smartphone device or desktop).
I wrote a script in HTML file in a content block, which will return an image (refered by ContentBlockbyKey) if displayed from a mobile device or else another image if displayed from desktop. However, image is not being rendered:
Here is the code:
<!DOCTYPE html>
<html>
<head>
<title>Mobile Test</title>
</head>
<body>
<p id="text"></p>
<script type="text/javascript">
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
var element = document.getElementById('text');
if (isMobile) {
contentblockbykey("4c824534-5e58-4003-99b3-716ccb7c8ba1")
} else {
contentblockbykey("95198c2a-2eb6-40e1-b3dc-4dae980d7c96")
}
</script>
</body>
</html>
Second Question:
Is it possible to know which device is the email being viewed from using Ampscript?