Skip to content Skip to sidebar Skip to footer

Dynamic Link Actions In Mailchimp

I need to do dynamic link opening based on each of 3 cases. How do I write this into a link ? Case 1: user is on desktop or Android. Send user to website link with reference to co

Solution 1:

You are looking for the concept of deep linking. I can help you with 2 of your cases

First I'll explain how I would attempt to make this work. This sample will open the Facebook app and navigate to the Wikipedia page. You can try this out by opening this link from your Android or iOS device.

  1. Instead of having the direct link in the email itself, I'd use one link that would then, on the server's side, determine the action to take.

In your email template, do this

<span>A brief funny description about this place, in one or two phrases... 
   <ahref="http://example.com/my_server_script.php"target="_blank">Read More</a></span>

This should then take the user to a script named 'my_server_script.php' (my example is PHP, but you can achieve this in any language).

  1. In this script, you can then check the User Agent by using PHP's $_SERVER['HTTP_USER_AGENT']. This will give you something like Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418 (KHTML, like Gecko) Safari/417.9.3. Then by parsing this string, you can determine the user's OS and take an action based on that. Please do note that User Agent strings can be modified and is not always 100%, but it should be more than enough for your use.

  2. Once you have determined the action to take, you could redirect the user to the app by sending them to the deeplink.

Here is PHP code I tested on Android earlier, this should open the Facebook app and take you to the Wikipedia page. As far as I know, it should work on iOS as well.

<?php// Set App deeplink$app_url = 'fb://profile/33138223345';

    // Try to redirect the device to the URL
    header('Location: ' . $app_url);
    ?>
  1. I don't have a solution for detecting if the app is installed, but if you do find a solution for that, you should be able to redirect them to the appropriate app store using the code below

    <?php// iTunes link$app_install_link = 'https://itunes.apple.com/za/app/facebook/id284882215?mt=8';
    
    // Then redirect the user to the app store location
    header('Location: ' . $app_install_link);
    ?>
  2. If you determine they should be sent to the desktop version, simply do

    <?php// Browser link$link = 'https://example.com/content/123';
    
    header('Location: ' . $link );
    ?>

This is personally how I would make this work since you won't have the capability in the email itself to check what device you are on and modify the link based on that.

You should however still be able to use the deeplink fb://profile/33138223345 by doing

<span>A brief funny description about this place, in one or two phrases... 
        <ahref="fb://profile/33138223345"target="_blank">Read More</a></span>

and that should open the Facebook app on iOS and Android.

Hope this helped a bit!

Post a Comment for "Dynamic Link Actions In Mailchimp"