Adobe DTM Data Element Updating

前端 未结 1 1157
独厮守ぢ
独厮守ぢ 2021-01-07 05:58

I\'m looking for a way to dynamically update a pre-defined data element in DTM. Once the page loads and the data elements are initialized it is not possible to update them,

相关标签:
1条回答
  • 2021-01-07 06:24

    In order to set a persistent data element to a new value, you need to first update whatever source the data element is based off of, and then use _satellite.getVar('element_name_here') to force evaluation of the data element.

    The key here is that on page load, the order of operations for a persistent data element is basically:

    1. Look for the satellite cookie and return that value
    2. Look for the specified target for the type (e.g. path (js var) for type JS Object) and return that value
    3. Return the default value

    But when you explicitly call _satellite.getVar('Example'), the order of operations is instead:

    1. Look for the specified target for the type (e.g. path (js var) for type JS Object) and return that value
    2. Look for the satellite cookie and return that value
    3. Return the default value

    Data Element Example:

    Name: Example

    Type: JS Object

    Path: someVariable

    Default Value: default value

    Remember this value for: Session

    So let's say I have on the page the following (set prior to DTM script tag):

    someVariable = 'foo';
    

    This will make available a data element named "Example" which you can reference with %Example% or _satellite.getVar('Example'), depending on the context.

    For the duration of the session, the data element will have that value "foo". So to change it, you would do the following:

    someVariable='bar';
    _satellite.getVar('Example');
    

    You can call this within your own script somewhere, or if you want to throw this into the mix for e.g. a page load rule, you can add it as a condition inside a Criteria > Data > Custom code box (note: if you put it here, add a return true; as 3rd line), etc..

    As an alternative, if you are feeling more adventurous, or need a work-around for your data element setup (e.g. your data element is type Custom Script and you need to sidestep the logic in there)..

    When you have a data element configured to be persistent, it sets a cookie named

    _sdsat_[data element name]

    So in the example above, it sets a cookie named

    _sdsat_Example

    So, if you really wanted to, you can instead just update the cookie with the new value, and just let the default order of operations return the (now updated) cookie value. (note: since it's not possible with javascript to get the expiration of a cookie, if you are setting the scope to "Visitor", you can set the expiration to 2 years, which is what DTM does)

    0 讨论(0)
提交回复
热议问题