Support » Plugin: Advanced Ads – Ad Manager & AdSense » Get Ads using javascript

  • Resolved Lisa Jong

    (@lisajong)


    Hi Thomas,

    I am having this tricky situation here and if you can provide any idea of how to implement this I would greatly appreciate your help.
    So Advanced Ads works perfectly on some pages of our website, like those sticker ads on this page. However, for some pages the content is filled by javascript from an external feed, like this page. Is there a recommended way of how to get Ads and insert them as part of the content using javascript? If you can give me any idea, really, any idea would be great.

    Thank you in advance!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Thomas M

    (@webzunft)

    Hi Lisa,

    thanks for reaching out.

    I am not seeing JavaScript output on the second page. Did you remove it?
    Do you experience issues when having ads in the content that is loaded on your site using AJAX (the one appearing when “Load more” is finished)?

    Thanks,
    Thomas

    Thread Starter Lisa Jong

    (@lisajong)

    Hi Thomas,

    Thank you for replying, wow this is fast. On this page all the news blocks are fed from a json by javascript. For every 5 news, the sixth block would be an Ad (it’s a grey box for now). I am trying to find a way to replace these grey boxes with Ads I set up in Advanced Ads, using javascript.

    Thanks,
    Lisa

    Plugin Author Thomas M

    (@webzunft)

    Hi Lisa,

    how is this sixth small-ad placeholder added right now? If you can influence this then there might be a way for Advanced Ads to place an ad there. I don’t think we can place something there right now after the content is loaded via JavaScript, so best is to hook in before that happens.

    Thomas

    Thread Starter Lisa Jong

    (@lisajong)

    Hi Thomas,

    The javascript was written by us to place those news blocks. Would you please give me a rough idea of how to “hook in” the ads in our javascript code? It’s OK if we have to make some changes in php code too. Thank you!

    Lisa

    Plugin Author Thomas M

    (@webzunft)

    Hi Lisa,

    thanks for your reply.

    If I understand correctly then your JavaScript code is generated using PHP, right?
    You can load the content of an ad, a group or placement using the theme functions listed on https://wpadvancedads.com/codex/theme-functions/.

    Does that help?

    Thomas

    Thread Starter Lisa Jong

    (@lisajong)

    Hi Thomas,

    Thank you. Unfortunately our javascript code isn’t generated by PHP. It’s written and placed to a specific page using another plugin. So this part is a pure frontend development. But you are right! If I move the generation of the javascript to backend I can use all those functions provided then. I believe this is the route we should go. Thank you again for your help!

    Lisa

    Plugin Author Thomas M

    (@webzunft)

    Perfect. Let me know if you need anything.

    Thomas

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Get Ads using javascript’ is closed to new replies.