Salesforce

Tagging guide 3 - advanced features

« Go Back
Information
Tagging guide 3 - advanced features
Tagging-guide-3-advanced-features
Details

Overview

This article describes extra features you can use for Equativ ad tags. 

Related articles

Refreshing ads

To refresh ads, use the sas.refresh([formatId], [options]) method.

sas.refresh([formatId]) / sas.refresh([tagId])

When using sas.refresh, the following rules apply for the formatId:
 
  • the formatId can be integer, string or array
  • if no formatId is specified, all the ad calls done in the page will be reloaded
  • if a formatId is specified, the ad will be called using the standard call type; this applies even if the ad was previously called using the OneCall call type
The sas.refresh method can also be applied to tagIds. 

sas.refresh([options])

Options available for sas.refresh:
  • forceMasterFlag – Forces the master flag which is used for page view counting. If the master flag is true, the ad call returns an ad (as usual) and the ad call is logged and reported as a page view (page impression); type: boolean, default value: false;
  • resetTimestamp – Resets the timestamp which is used for features such as links (displaying ads from insertions always together on a page) or exclusions (never display ads from certain insertions together on a page); type: boolean, default value: true;
  • target – Updates the target criteria for the specified format. For more information on the target parameter, see above chapters; type: string, default value: undefined; you can alter the target criteria of a specified format. The following rules apply:
    • If the target option is unspecified (value undefined), the original target will not be altered.
    • If the target option is set to an empty string (""), the target will be cleared.
    • If the target option is set to a non-empty string, the specified string will become the new target.

sas.refresh method examples 

Note: sas.refresh() does not depend on the call type. If no format id is specified, all calls done in the page will be reloaded. If a format id is specified, a "standard" call will be generated for the placement, even if it was previously loaded by a "onecall" call.
// refresh the format id 12345
sas.refresh(12345);
// refresh the format and force master flag
sas.refresh(12345, { forceMasterFlag: true });
 
// refresh all formats
sas.refresh();
// refresh all formats and force master flag
sas.refresh({ forceMasterFlag: true });
 
// refresh all formats and clear the target
sas.refresh({ target: "" });
// refresh all formats and update the target
sas.refresh({ target: "age=42" });
 
// refresh the format id 12345 and update its target
sas.refresh(12345, { target: "sex=m" });

// refresh the format id 12345, update its target, and force master flag
sas.refresh(12345, { target: "country=uk", forceMasterFlag: true });

// refresh the tagId sas_tag_001 and update its target 
sas.refresh("sas_tag_001", { target: "sex=m" });
 

Lazy loading

With lazy loading, ads are called when users are likely to actually view them, e. g. an ad at the bottom of the page can be called only when the user actually scrolls there. This optimizes page loading time, reduces latency and increases the ad viewability score.

Once lazy loading is enabled, inventory availability shown in the Forecast will drop for the lazy loaded formats; this behavior is expected since users that do not scroll down to the lazy loaded formats will not trigger any ad call to Equativ anymore.
 
Parameter            Type       Default valueDescription                                                                                                            
fetchRatioFLOAT0.1optional; defines the "distance" between the current viewport and the ad container at which the ad call will be triggered; e.g. fetchRatio: 0.3 will trigger the ad call when the ad container is 30% away from the current viewport;
mobileFetchRatioFLOAT0.8optional; defines the "distance" between the current viewport and the ad container at which the ad call will be triggered; applies to mobile devices; e.g. fetchRatio: 1.0 will trigger the ad call when the ad container is one viewport away from the current viewport
formatsINTEGERn/aoptional; the list of lazy loaded formats; recommendation: use formats that are down the page and unlikely to be seen; Warning: if none are provided, all formats will be lazy-loaded; 

Lazy loading example

The snippet below shows a lazy loading configuration using the sas.enableLazyLoading() method. The configuration is identical for both OneCall and Standard tagging.
// Configuration of lazy loading
    sas.cmd.push(function () {
    sas.enableLazyLoading({
        fetchRatio: 0.3, 
        mobileFetchRatio: 1.1,
        formats: [84313]

GDPR consent data

The consent object contains the consent payload, encoded as a base64 string (as specified by the IAB specifications).
Do not use this functionality if you use a valid, IAB compliant CMP. With a valid CMP, the smart.js library on the website is able to retrieve the user's consent string on its own. The sas.setGdprConsentData(consent) function sets the consent payload used by all the calls on the page. It overrides any consent payload stored in the cookies by CMPs.

Example

Note: sas.setGdprConsentData(consent) does not depend on the call type.
sas.setGdprConsentData("BONmEt0ONmEt0AtABBFRAR-AAAAJqABgAQASoA");

Extended user IDs

User Ids from third party user identification vendors can be sent in OneCall requests as an optional parameter of the sas.call() function; 
 
Note: Extended user IDs do not depend on the call type.

Read the Extended User Identification article for details including a sample.
 

Digital Services Act (DSA) transparency data

With the sas.setDsa function, you can declare the Digital Service Act (DSA) requirements for a website. In the ad response, Equativ will then provide the requested DSA transparency information.
Equativ follows the IAB’s DSA Transparency specification and supports all parameters of this specification.

Below is an example of the sas.setDsa function with its parameters:
 
sas.setDsa({dsarequired: 2, pubrender: 1, datatopub: 2, transparency:[{domain: example.com', dsaparams:[1]}]}); 
 

Seller defined Audiences/Context data

Seller Defined Audiences (SDA) and Seller Defined Context (SDC) data can be sent using the methods:
  • sas.setSda for SDA (corresponds to the user.data object in open RTB integrations)
  • sas.setSdc for SDC (corresponds to the site.content.data object in open RTB integrations)
If multiple updates are sent, the updates are merged.
For more details about SDA/SDC, see Seller Defined Audiences/Context implementation.

Sda / Sdc object

KeyTypeDescription
idSTRINGAn exchange-specific ID for the data provider.
nameSTRINGAn exchange-specific name for the data provider.
segmentOBJECT ARRAYAn array of Segment objects that contain the actual data values.

Segment object

KeyTypeDescription
idSTRINGThe ID of the data segment specific to the data provider.
nameSTRINGThe name of the data segment specific to the data provider.
valueSTRINGThe string representation of the data segment value.

Sample

The sample below shows how SDA data are sent using the sas.setSda. The syntax is identical in case of the sas.setSdc method.
 
sas.setSda([
    {
        name: 'myDataprovider1.com',
        id: '1',
        segment: [
            {
                id: '1',
                name: 'mySegment1',
                value: '100',
            },
            {
                id: '2',
                name: 'mySegment2',
                value: '200',
            },
        ],
    },
    {
        name: 'myDataprovider2.com',
        id: 'myId',
        segment: [
            {
                id: 'mySegmentId1',
                name: 'mySegmentName1',
                value: 'mySegmentValue1',
            },
            {
                id: 'mySegmentId2',
                name: 'mySegmentName2',
                value: 'mySegmentValue2',
            },
            {
                id: 'mySegmentId3',
                name: 'mySegmentName3',
                value: 'mySegmentValue3',
            },
        ],
    },
]);
 

Header Bidding data

Equativ's unified auction offer allows you to run a full competition between direct (premium) campaigns, Equativ's RTB and 3rd party SSPs (server-side and client-side header bidding): the highest bid will win while making sure that direct campaigns will deliver their guaranteed targets (volumes).

The sas.setHeaderBiddingWinner(tagId,headerBidding)function sets the data of the header bidding winner (for details click here) for a specific tag id; 

The headerBidding object has the following header bidding data:
 
  • bidder – name of the bidder; type: string;
  • cpm – bidder CPM; type: number;
  • currency – CPM currency symbol ("EUR", "USD", etc.); type: string;
  • dealId – (optional) deal id in case of a preferred deal; type: string;

Examples

Note: sas.setHeaderBiddingWinner(tagId,headerBidding) works with OneCall tagging with POST method only.
// no deal
sas.setHeaderBiddingWinner("myTagId", {
    bidder: "AppNexus",
    cpm: "1.4",
    currency: "USD"
});

// with deal
sas.setHeaderBiddingWinner("myTagId", {
    bidder: "AppNexus",
    cpm: "1.4",
    currency: "USD",
    dealId: "12334-ad-1267821-fhe"
});

Events

Note: Events do not depend on the call type.

The sas.events.on("event", callback, id) function will register a callback to the specified event:
 
  • event – string: the event to listen to;
  • callback(data)– function: called every time the event is fired;
  • id – string: optional, allows you to filter an event and to be notified only on this id;

Supported events

 
  • "call" : triggered every time sas.call is called
    • data – object: contains the data provided in sas.call (callType, ad, options)
    • id – represents the tagId
var onCallCallback = function(event) { /* put your event logic here */ };

// register to all "call" events
sas.events.on("call", onCallCallback);

// register to standard call events
sas.events.on("call", onCallCallback, "std");
 
  • "noad": triggered every time there is no ad in a placement
    • data –  object: contains the placement data (formatId, instance, tagId)
    • id –  represents the tagId
var onNoadCallback = function(event) { /* put your event logic here */ };

// register to all "noad" events
sas.events.on("noad", onNoadCallback);

// register to noad only for tag "sas_1234"
sas.events.on("noad", onCallCallback, "sas_1234");
 
  • "clean": triggered every time a placement is cleaned
    • data –  object: contains the placement data (formatId, instance, tagId)
    • id –  represents the tagId
If it exists, call the onClean callback of the given format. The clean callback is defined by the option onClean in sas.call.
If no format id is specified, all formats of the page will be cleaned.
// clean the format 300
sas.clean(300);

// clean all formats
sas.clean();
 

Callbacks

  • onLoad – callback is called after an asynchronous call has been successfully performed;
  • onError – callback is called in case an error occurred during the call;
  • onClean(formatId, element) – callback is called before cleaning the placement;
  • beforeRender(data) – callback is called before the format rendering (sas.render); it is only called when OneCall tag call has returned; if sas.render is called before the OneCall has returned (sas_manager created), beforeRender will not be called; the data (object) contains the rendering context (formatId, tagId);
  • onAd(data) – callback is called when Equativ returns an ad to be displayed for a given format;
  • onNoad(data) – callback is called if there is no ad to display for the given format, if provided for callType="onecall"; the callback will be triggered for each empty format; data.tagId (string): the tag id of the noad; data.formatId (string): the format id of the noad;
The callbacks are also listed in the “sas.call([options])” table of the Tagging guide 1 - overview article
Note: onLoad could be used to execute javascript in case of empty ad responses (noad). However, the onNoad(data) callback function is the recommended method for this purpose.

Retrieving event history

The sas.events.history("event") function  is used for debugging purposes and it allows you to retrieve all events already fired, i.e. it lists all the events triggered by smart.js in the console; event (string) is the event name (optional). 

This function can be useful to retrieve all calls that should have been done before you register to sas.events.on("call").

Examples

Note:  sas.events.history("event") does not depend on the call type.
// retrieve all events already fired
var events = sas.events.history();

// retrieve all "noad" events already fired
var noadEvents = sas.events.history("noad");
 

Updating the keyword targeting string

The keyword targeting string is set with the smart.js library when it is initialized. After the initialization, you can use the sas.setTargeting() method to update the keyword targeting string. This function is available for both OneCall and StandardCall.
 
ParameterTypeNecessityDescription
targetobjectrequiredthe targeting criteria in format: { keywordA:['value1'], keywordB:['value2'] }
format of the resulting targeting string: keywordA=value1;keywordB=value2
a keyword accepts one or multiple values as an array of strings: keywordA:['value1','value2']
modeintegeroptionalthe updating mode with one of the following values:
  • 0 (default) — the previous targeting string is erased and the new one is set
  • 1 — the previous targeting string is preserved and the new targeting criteria are appended; if a key was already set, its previous value will be overridden by the new value
  • 2 — the previous targeting string is preserved and the new targeting criteria are appended; if a key was already set, its previous value will not be overridden by the new value; instead, the new value is appended to the previous one, while ensuring there are no duplicate values
tagIdsstringoptionalthe tagIds affected by the update;
if an empty array [] is set or if the key is not provided, all tagIds are affected;
default format of tagIds: sas_[formatId]
Example
sas.setTargeting({
  target: {
    keywordA: ['value1','value2'],
    keywordB: ['value3']
  },
  mode: 1,
  tagIds: [sas_84313]
})

 

Related articles


Powered by