Expand my Community achievements bar.

Join us for an upcoming in-person Adobe Target Skill Builders event ~~> We're hosting these live learning opportunities to equip you with the knowledge and skills to leverage Target successfully. Learn more to see if we'll be coming to a city near you!
SOLVED

adobe.target.trackEvent() failing while getOffer() is working

Avatar

Employee Advisor

Hi,

I am trying to track some CTAs and I am using trackEvent method for that. But when I am clicking on the button, the request goes into 400 status.

The workaround to this I opted is to go for getOffer() method but just curious to see the reason behind failure of trackEvent method. Any help will be much appreciated. thanks!

Below is the code - 

 

el.addEventListener('click', function (e) {
                    e.preventDefault();
                    console.log("CTA clicked")
                    adobe.target.trackEvent({
                        "mbox": "carouselCTA"
                    });
                    // adobe.target.getOffer({
                    //     "mbox": "carouselCTA",
                    //     "success": function (offer) {
                    //         adobe.target.applyOffer({
                    //             "mbox": "carouselCTA",
                    //             "offer": offer
                    //         });
                    //     },
                    //     "error": function (status, error) {
                    //         console.log('Error', status, error);
                    //     }
                    // });
                    setTimeout(function () {
                        window.open(el.href, '_blank');
                    }, 1000);
                });

 

Target version - 2.3.2

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@Khushboo_Kalia  the code seems to be fine. I have seen such issues related to the browser extensions or network settings.

Hope this helps.

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @Khushboo_Kalia 

I tried the below code at my end seems is working fine for me with target version 2.7.0. 

const el = document.getElementByClassName("hero_btn")[0];
el.addEventListener('click', function (e) {
                    e.preventDefault();
                    alert("CTA clicked")
                    adobe.target.trackEvent({
                        "mbox": "carouselCTA"
                    });
                    setTimeout(function () {
                        window.open(el.href, '_blank');
                    }, 1000);
                });

 

I can see there was some issues with version 2.1.0 for trackEvent function however that got fixed in later release so shouldn't be the problem. 

 

If still having problem then it's worth to try to upgrade target version in lower environment and check again. 

Hope this helps. 

Avatar

Correct answer by
Employee Advisor

@Khushboo_Kalia  the code seems to be fine. I have seen such issues related to the browser extensions or network settings.

Hope this helps.

Avatar

Employee Advisor

@Gaurav_Singh That seems the issue but I couldn't tackle which extension that will be in my case.

Avatar

Community Advisor

Hi @Khushboo_Kalia Sometimes Adobe experience cloud debugger (old) browser extension make an issues with so just try disabling and see if that works for you.