Expand my Community achievements bar.

SOLVED

Adobe Target integration with AEM

Avatar

Level 2

We have few buttons on our webpage. When "documentContentLoaded" event is fired, we are assigning event listener to the buttons. We have added target script in the head section and our client library is near the closure of body tag. Sometimes, target script is loading before our client and vice versa. When our client library is loaded before target script, event listeners get assigned to the buttons. Then target script loads which replaces HTML body with a new body. This deletes old buttons and adds the same buttons again. Due to this, event listeners aren't working. This doesn't happen if target scripts loads before our client library. What is a possible solution to load target script before client library.

1 Accepted Solution

Avatar

Correct answer by
Level 10
6 Replies

Avatar

Level 7

Hi,

how you are using target library into your AEM site?

Are you including it by using cloudservices configuration?

Let us know.

Thanks,
Antonio

Avatar

Level 10

The Target libraries are supposed to be loaded synchronously in the page head. Can you validate that?

How do you load the clientlibs - in sync or async?

In a nutshell, if you've same elements, say button on both parent-DOM and on target-DOM and you want to manage both by your parent DOM and not by target's provided bindings, you'd have to bind both DOMs with appropriate event listeners to solve for this issue. Make sure that you unbind first and then bind to avoid double binding issues and add relevant missing element/container checks to avoid js errors.

Based on the sequence order loading of scripts, bind both of them in DOM ready or onload as applicable including target-DOM..

Avatar

Level 2

We are using Adobe launch. We have added added the dtm script using script tag in head.

Avatar

Level 2

We haven't specified sync or async attribute on script tags. So, i think sync is the default.

Avatar

Correct answer by
Level 10

Avatar

Level 10

I would recommend to go through code or test it to understand if mbox/at.js and your clientlibs load in sync or async irrespective of the fact that one is in head and other is in the body. Once you test and get to know, tweak the implementation accordingly.