Skip to content
This repository has been archived by the owner on Jun 19, 2021. It is now read-only.

init method is not working #5

Open
Vishanth opened this issue Jun 24, 2019 · 7 comments
Open

init method is not working #5

Vishanth opened this issue Jun 24, 2019 · 7 comments

Comments

@Vishanth
Copy link

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!

@sobolevn
Copy link
Member

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

@Vishanth
Copy link
Author

@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.

@sobolevn
Copy link
Member

See #4

@aboutsam
Copy link

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?

@srchulo
Copy link

srchulo commented Jun 18, 2020

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 })

@hanenouche
Copy link

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

@srchulo
Copy link

srchulo commented Jun 30, 2020

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants