0

Is there a possibility to export or generate a report for bitly link sent through SMS with mobile connect?

Thanks in advance

1
  • no there is not
    – EazyE
    Commented Feb 25, 2021 at 14:47

1 Answer 1

0

No, there is no possibility to track OOTB Bit.ly shortener within Mobile Connect, however, as an alternative, you can shorten your links via API calls saved in the Code Snippet and simply bring it to the SMS text by %%=ContentBlockByID(...)=%%

The code snippet would contain -

<script language="javascript" runat="server">
Platform.Load("Core", "1");
try{
</script>
        
%%[
    VAR @Link, @utm_campaign, @utm_source, @utm_medium, @utm_id, @sfmc_id, @Parameters, @FullURL, @AccessToken, @Payload, @PostRequest, @Response, @ResponseRows, @json, @ShortenURL

    /* Set the link and parameters you want to track */
    SET @Link = ""

    SET @utm_campaign = ""
    SET @utm_source   = ""
    SET @utm_medium   = ""
    SET @utm_id       = ""
    SET @sfmc_id      = ""

    /* Prepare your full link */
    IF NOT EMPTY(@Link) THEN
        IF EMPTY(@utm_campaign) AND EMPTY(@utm_source) AND EMPTY(@utm_medium) AND EMPTY(@utm_id) AND EMPTY(@sfmc_id) THEN
            SET @FullURL = URLEncode(CONCAT('"', @Link, '"'))
        ELSE
            SET @Parameters = CONCAT("?utm_campaign=", @utm_campaign, "&utm_source=", @utm_source, "&utm_medium=", @utm_medium, "@utm_id=", @utm_id, "&sfmc_id=", @sfmc_id)
            SET @FullURL = URLEncode(CONCAT('"', @Link, @Parameters, '"'))
        ENDIF
    ENDIF

    /* Change 'xxx' to your personal access token */
    SET @AccessToken = 'xxx'

    /* Change 'xxx' to the Group ID this link would be associated with and 'yyy' to either default 'bit.ly' domain or your custom one */
    SET @Payload     = CONCAT('{"group_guid": "xxx", "domain": "yyy", "long_url": ', @FullURL, '}') 
    SET @PostRequest = HTTPPost2("https://api-ssl.bitly.com/v4/shorten", "application/json", @Payload, False, @Response, @ResponseRows, "Authorization", CONCAT("Bearer ", @AccessToken))

    IF @PostRequest == '200' THEN
        SET @json = @Response
    ENDIF
]%%

<script language="javascript" runat="server">
    /* Receieving json from POST request and parsing it to get the link */
    var json       = Variable.GetValue("@json");
    var ParseJSON  = Platform.Function.ParseJSON(json);
    var ShortenURL = ParseJSON.link;
    Variable.SetValue("@ShortenURL", ShortenURL);

    }catch(e){
        Write(Stringify(e));
    }
</script>

However, to make it work, you would need to get in advance several things:

  1. Link address you want to shorten
  2. Access token that you need to generate in your Bit.ly admin panel
  3. Ask Bit.ly to create several Groups if you would want to differentiate your links by brand or region, for example (optional)
  4. Retrieve guid (= Group ID) by doing an API call (optional)
  5. Only once those values are set, you would be able to output the result like - %%=v(@ShortenURL)=%%

Other points to consider:

  1. Check official API documentation, where you can find other things like customizing your links
  2. Set more variables to match the custom field in SMS SendLog for better tracking
  3. Set better error handling, since SSJS is already in place

You must log in to answer this question.

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