Jump to content

Integration adzone in vuejs-application


iparker

Recommended Posts

Hello,

what is the best way to integrate an adzone in a vuejs application? 

Which kind of snippet/code of banner invocation is the best way?

How can I handle a new banner-request when clicking inside the vuejs single page application?

Thanks for some help!

Best regards,

Timo

Link to comment
Share on other sites

I tried to create a simple component for the banner invocation code like this:

<template>
  <div class="d-flex justify-center">
    <!-- Ad-Server Asynchronous JS Tag - Generated with Revive Adserver v5.0.2 -->
    <ins
      :data-revive-zoneid="reviveZoneId"
      :data-revive-id="reviveId"
      data-revive-target="_blank"
    ></ins>
    <script
      async
      src="//adserver-url/asyncjs.php"
    ></script>
  </div>
</template>

<script>
  export default {
    name: 'JobListingBanner',
    props: {
      reviveZoneId: {
        type: String,
        required: true,
      },
      reviveId: {
        type: String,
        required: true,
      },
    },
    mounted: function () {
      console.log('Banner Mounted!');
    },
  };
</script>

<style scoped></style>
 

But this does not work correctly. The banners are loaded the first time, but when I paginate through a listing the banners disappear. 

I tried to rerender the vue component but this also not works.

Maybe the problem is the asynch js? 

Hope you can help me with this!

Best regards,

Timo

Link to comment
Share on other sites

  • 5 months later...
On 1/14/2021 at 9:35 PM, iparker said:

Hello,

what is the best way to integrate an adzone in a vuejs application? 

Which kind of snippet/code of banner invocation is the best way?

How can I handle a new banner-request when clicking inside the vuejs single page application?

Thanks for some help!

Best regards,

Timo

we are running in to the same issue, we are trying to use revive in a NuxtJS app. We experience the exact same behavior as you have here.

were you able to fix it? 

Thanks,
S.

Link to comment
Share on other sites

  • 11 months later...

There is a workaround which solved the same issue for me:

See: https://github.com/revive-adserver/revive-adserver/issues/725

 

Basically:

Run this code after you change the view in SPA.
reviveAsync.{your-data-revive-id}.apply(reviveAsync.{your-data-revive-id}.detect());

 

I made a Vue Component which calls this function in it's mount hook.

 

<template>
<div>
  <ins :data-revive-zoneid="zoneId" :data-revive-id="reviveId" data-revive-target="_blank"></ins>
  <component is="script" src="https://revive.sonares.org/www/delivery/asyncjs.php" async></component>
</div>
</template>
 
<script>
 
export default {
  name: 'ReviveAd',
  props: {
    zoneId: Number,
    reviveId: String
  },
  mounted() {
    this.reviveRefresh()
  },
  methods: {
    reviveRefresh() {
      console.log("revive refresh")
      if (window.reviveAsync) window.reviveAsync[this.reviveId].apply(reviveAsync[this.reviveId].detect())
    }
  }
}
</script>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...