Giter Site home page Giter Site logo

vue-analytics-facebook-pixel's Introduction

vue-analytics-facebook-pixel

Deprecated, use alternatives

npm

A small wrapper around fbq. This package integrates Facebook pixel into your Vue app.

Installation

npm install vue-analytics-facebook-pixel

Also, this library requires installing Facebook Pixel API.

Usage

Preparations

import Vue from 'Vue'
import VueFacebookPixel from 'vue-analytics-facebook-pixel'

Vue.use(VueFacebookPixel)

Calling API

To start using this script you will have to call init(...) first.

/**
 * Init facebook tracking pixel
 * @param  {String} appId
 * @param  {object} [data={}]
 */
Vue.analytics.fbq.init('YOUR_FACEBOOK_CODE', {
  em: '[email protected]'
})

Make sure init(...) is called only once.

Then you will have full access to the event(...) method.

/**
 * Event tracking
 * @param  {String} name
 * @param  {object} [data={}]
 */
Vue.analytics.fbq.event('ViewContent', {
  content_name: 'Really Fast Running Shoes'
})

Inside component

All component instances can call this.$analytics.fbq

Naming convention

All vue-analytics-* share the same analytics object, where all the providers are stored.

Facebook script

Facebook Pixel API is required to be installed. You can skip the default window.fbq('init', 'KEY') part and use Vue.analytics.fbq.init(...) which will do the same.

vue-analytics-facebook-pixel's People

Contributors

jamiewarb avatar sobolevn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vue-analytics-facebook-pixel's Issues

need to guide more detail...

I configured initial setup as README.md but it isn't working.
So I added code in below and it is working.

    <script>
      !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');
    </script>

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!

faq is not defined error

스크린샷 2020-03-27 오전 11 34 25

스크린샷 2020-03-27 오전 11 35 02

import Vue from "vue";
import VueFacebookPixel from 'vue-analytics-facebook-pixel';
Vue.use(VueFacebookPixel);
Vue.analytics.fbq.init(KEY, { em: EMAIL })

Developer console shows me error log.
How to solve this??

Decent, modern Facebook Pixel API loading

Has anyone rewritten this in a Vue-ish way?

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');

Maybe with vue-plugin-load-script and meaningful variable names?

enhancement request: integrate with vue-router

Similar to vue-analytics, allow passing a router instance as an option:

import router from './router'
import VueFacebookPixel from 'vue-analytics-facebook-pixel'

Vue.use(VueFacebookPixel, { router })

and automatically fire 'PageView' on route change

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.