vue-analytics-facebook-pixel icon indicating copy to clipboard operation
vue-analytics-facebook-pixel copied to clipboard

init method is not working

Open Vishanth opened this issue 6 years ago • 7 comments
trafficstars

I tried the following

from the main:

  • Vue.$analytics.fbq.init('AppID', {em: });
  • Vue.analytics.fbq.init('AppID');

from the vue page:

  • this.$analytics.fbq.init('AppID', {em: });
  • this.$analytics.fbq.init('AppID');

But adding the script from Facebook Pixel initializes properly. What's the right way of initializing through the analytics.fbq.init() method?

Cheers!

Vishanth avatar Jun 24 '19 06:06 Vishanth

What do you mean by not working? Exception? No data collected?

sobolevn avatar Jun 24 '19 08:06 sobolevn

@sobolevn

I used fbq.init() method giving my app id but the event is not firing to the Facebook pixel (no data collected). However, it works if I use the Facebook pixel's code under <script> tag in index.html.

Not sure if I have missed something there or I may not be calling the Vue.analytics.fbq.init('AppID'); correctly.

Vishanth avatar Jun 25 '19 00:06 Vishanth

See https://github.com/wemake-services/vue-analytics-facebook-pixel/issues/4

sobolevn avatar Jun 25 '19 07:06 sobolevn

same issue here

what i have done:

  1. Add npm package
  2. add snippet in my index.html
  3. create init()
  4. load in my component

my error msg:

[Vue warn]: Error in mounted hook: "TypeError: this.$analytics.fbq is not a function"

pixel was find, but i cannot call from my component. did you have any advise?

aboutsam avatar Apr 15 '20 14:04 aboutsam

init also didn't work for me. I had to add the snippet from #4 , but I also had to init in my JS that I put in a <script> tag:

        !function(f,b,e,v,n,t,s)
        {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
        n.callMethod.apply(n,arguments):n.queue.push(arguments)};
        if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
        n.queue=[];t=b.createElement(e);t.async=!0;
        t.src=v;s=b.getElementsByTagName(e)[0];
        s.parentNode.insertBefore(t,s)}(window, document,'script',
        'https://connect.facebook.net/en_US/fbevents.js');
        fbq('init', 'xxxxxxxx');

After that, passing in the router tracked each page view:

Vue.use(VueFacebookPixel, { router, debug: true })

srchulo avatar Jun 18 '20 19:06 srchulo

same issue

Please @srchulo can you explain more about how we can use facebook pixel in a vue project, so what I did , is adding the script from #4 to my head tag in index.html file, after that I added VueFacebookPixel into my main.js but with the Facebook pixel helper extension, no pixel is added to my vuejs project

hanenouche avatar Jun 29 '20 23:06 hanenouche

@hanenouche I just put the code from my comment above in my script tag in head, and then did this:

Vue.use(VueFacebookPixel, { router })

And make sure to replace

fbq('init', 'xxxxxxxx');

With your own ID.

srchulo avatar Jun 30 '20 03:06 srchulo