How should I correctly use the FbPlayableAd.onCTAClick() function?

Hi, I’m trying to make a Playable Ads for Meta. I’ve successfully merged assets into one single HTML file and reduce the size but I don’t get the part where should I use the FbPlayableAd.onCTAClick() function in my code. I simply want to attach it to button.

You call the function as part of a PlayCanvas button click callback or other PlayCanvas input event

can you give me an example a code snippet or in a project please, that’d help me a lot

There’s one in the example project in the documentation Facebook Playable Ad | PlayCanvas Developer Site

1 Like

sorry for late respond I’ve tried to apply it but nothing happens when I click on button.

Here’s my scene : PlayCanvas | HTML5 Game Engine

When testing on a desktop browser or in the FB ads manager?

I had a look at your project and can see that it will call FbPlayableAd.onCTAClick() if the FB SDK is available. The FB SDK gets added by the ad window on Facebook and you can test it via FB Ads manager as outlined in the docs: Facebook Playable Ad | PlayCanvas Developer Site

It won’t do anything in the launch tab because the FB SDK is NOT available and therefore the check in the code stops FbPlayableAd.onCTAClick() being called because the object doesn’t exist.

        if (window.FbPlayableAd) { // This line checks if the FB SDK is available in the window scole

Thank you, that worked. I was confused why it was not working.