Expand my Community achievements bar.

SOLVED

Firing events based on dataelemt or variable value - WebSDK

Avatar

Level 3

When using web sdk, can we set the below logic - 

If datalayer object say "xViewed" = "Yes" when X banner/component has been viewed, then fire event1 i.e. XViewed

But if value = No, then don't fire the event.

Also xViewed is available on the datalayer for a pageview event i.e. there is no event in the datalayer/ no new payload when X banner/component has been viewed

 

I believe that an xdm data element and launch rule need to be set for the event page view but how can we set the "xViewed" event when value of the datalayer element is 'Yes'

How do we configure this when using Web SDK?

 

Thanks

 

@yuhuisg 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Just to clarify:

You're using the Adobe Client Data Layer, where your data layer in the web page code is called "adobeDataLayer" and you're also using the Adobe Client Data Layer in your Tags property.

Your sequence of events is:

  1. User opens a page. --> "xViewed" gets pushed into the data layer with a value of either "Yes" or "No". You send a Web SDK event in a Rule -- what event(s) are you using to trigger this Rule?
  2. User clicks a banner. --> something gets pushed into the data layer. You send a Web SDK event in a Rule -- what event(s) are you using to trigger this Rule?

Also at step 2, in your Web SDK event, you want to send "event1" only when "xViewed" at step 1 was "Yes".

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Just to clarify:

You're using the Adobe Client Data Layer, where your data layer in the web page code is called "adobeDataLayer" and you're also using the Adobe Client Data Layer in your Tags property.

Your sequence of events is:

  1. User opens a page. --> "xViewed" gets pushed into the data layer with a value of either "Yes" or "No". You send a Web SDK event in a Rule -- what event(s) are you using to trigger this Rule?
  2. User clicks a banner. --> something gets pushed into the data layer. You send a Web SDK event in a Rule -- what event(s) are you using to trigger this Rule?

Also at step 2, in your Web SDK event, you want to send "event1" only when "xViewed" at step 1 was "Yes".

Avatar

Level 3

Hi @yuhuisg ,

Not using the ACDL. Using an EDDL instead. Will the sequence still apply?

What happens is in step 1 - on search result event, event type= search result will be pushed in the datalayer along with value of the variable say XToggled= Yes or No.  A rule should be triggered for this event (search result shown)

I'm thinking custom code might be needed to trigger the rule on the above event

 

Looking to fire another rule for XToggled if value is Yes (at the same time). If yes, how can I trigger these event using custom code?

 

Thanks

Avatar

Community Advisor

@hs_vk wrote:

Not using the ACDL. Using an EDDL instead. Will the sequence still apply?

Alright, not to worry. The sequence would still apply.


@hs_vk wrote:

What happens is in step 1 - on search result event, event type= search result will be pushed in the datalayer along with value of the variable say XToggled= Yes or No.  A rule should be triggered for this event (search result shown)

I'm thinking custom code might be needed to trigger the rule on the above event

If you're using an extension to help you work with your EDDL, e.g. if you're using Data Layer Manager by Search Discovery, then that extension should provide Event, Action and Data Element types that you can use in your Rules and Data Elements, so that you don't need to mess around with custom code. I don't use any such extensions, though, so I can't help you with them.


@hs_vk wrote:

Looking to fire another rule for XToggled if value is Yes (at the same time). If yes, how can I trigger these event using custom code?

Are you pushing any event into your EDDL when the user clicks the banner? If so, you could use that event to trigger this second Rule. Again, you probably don't need to use custom code if you're using an extension to help you use your EDDL efficiently.

Avatar

Level 3

Hi @yuhuisg 

Thanks so much for clarifying. Unfortunately I can't use an extension because of some limitations. Are there any alternatives to an extension to trigger the above events? Maybe there is an Adobe extension that I'd be able to use?

Avatar

Community Advisor

If you're using a dataLayer from Google Tag Manager, then you can use the Google Data Layer extension that is built by Adobe.

Otherwise, you'll have to rely on custom code. Hopefully, you know what code to write to detect pushes into your EDDL so as to trigger events and also get the correct, computed data layer values.

To trigger a custom code event in your Rule, you'll need to use the special "trigger()" function. Something like this:

if (dataLayer.computedEvent === 'click banner') {
  trigger(); // this function will cause Launch to trigger your Rule to run
}