vue-analytics-facebook-pixel
vue-analytics-facebook-pixel copied to clipboard
init method is not working
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!
What do you mean by not working? Exception? No data collected?
@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.
See https://github.com/wemake-services/vue-analytics-facebook-pixel/issues/4
same issue here
what i have done:
- Add npm package
- add snippet in my index.html
- create init()
- 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?
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 })
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 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.