Shortening of the title of ads and description

If you configured at admin UI, you can reduce ad title, explanation and advertiser’s name in order to optimize for each media. Please refer to the UI manual for details.

Editing by callback functions

Giving the callback functions allows you to adjust the length of the string in your optional manner. Callback functions will be called right before displaying ads. The content of ads and location will be given as an argument. At this point, you can describe the process to edit the content. And also, you can edit the number of characters of item according to the position. Callback functions should be given to before_render option. This before_render option overwrites length configurations of admin UI.

The following, place [PR] at the head of title. The number of characters of ad spots A should be within 30, and ad spots B should be within 40 including ellipses at the end of sentence.

RFP.InFeed.Default.run({
  before_render: function(ad_info, placement_info) {

    // Insert `[PR]` at the head of the title.
    ad_info.title = '[PR] ' + ad_info.title;

    // Assign the maximum length of description for each ad spots.
    var desc_max_len = 30;
    if (placement_info.adspot_id === 'ADSPOT_A') {
      desc_max_len = 30;
    } else if (placement_info.adspot_id === 'ADSPOT_B') {
      desc_max_len = 40;
    }

    // Keep the number of characters of description within maximum length, and add ellipses at the end of text
    if (ad_info.description.length > desc_max_len) {
      ad_info.description = ad_info.description.substr(0, desc_max_len - 1) + '…';
    }

    // Return the edit result
    return ad_info;
  }
});
  • Object of ads content will be given for the first argument of before_render. Please refer to ads parameter for object’s property.
  • Object of placement position will be given for the second argument of before_render. Object’s property is adspot_id (ad spots ID).
  • As for callback functions, the edited contents of ads object should necessarily be given back by return.