0

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?

3
  • 3
    This is a css question and belongs on Stack Overflow as this is unrelated to SalesForce Sep 21, 2019 at 23:40
  • @Gortonington - thank you, i'll post it there.
    – Nat Fan
    Sep 21, 2019 at 23:46
  • @Gortonington - i've updated my question, please review and comment.
    – Nat Fan
    Sep 23, 2019 at 21:20

1 Answer 1

1

AMPscript and SSJS are both server-side meaning they are run and processed prior to the email being sent. Anything 'client-side' would have to be done via CSS or 'live images' such as Movable ink or Live Clicker.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .