Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
src
.gitignore
.npmignore
CHANGELOG.md feat: 🎸 Update to IMA.js v17 Nov 28, 2019
LICENSE
README.md #! README.md updates Dec 2, 2019
gulpfile.js feat: 🎸 Update to IMA.js v17 Nov 28, 2019
index.js FacebookPixelAnalytic Aug 1, 2019
jest.conf.json FacebookPixelAnalytic Aug 1, 2019
package.json Fix merge conflicts Dec 2, 2019

README.md

@ima/plugin-analytic-fb-pixel

This is the Facebook Pixel analytic plugin for the IMA.js application. You can visit our site https://imajs.io.

Installation

npm install @ima/plugin-analytic-fb-pixel @ima/plugin-script-loader --save
// /app/build.js

var vendors = {
	common: [
		'@ima/plugin-analytic-fb-pixel',
		'@ima/plugin-analytic',
		'@ima/plugin-script-loader'
	]
};

/*
Now is FB Pixel analytic plugin available from:

import { FacebookPixelAnalytic, defaultDependencies } from '@ima/plugin-analytic-fb-pixel';
*/
// /app/config/settings.js

prod: {
	$Http: { ... },
	$Cache: { ... },
	$Page:{ ... },
	plugin : {
		analytic: {
			fbPixel: {
				id: 'XXX'
			}
		}
	}
}
// /app/config/services.js
import { FacebookPixelAnalytic } from '@ima/plugin-analytic-fb-pixel'
import { RouterEvents } from '@ima/core';

var $window = oc.get('$Window');
var $dispatcher = oc.get('$Dispatcher');
var fbPixelAnalytic = oc.get(FacebookPixelAnalytic);


if ($window.isClient()) {

	// initialize analytic
	fbPixelAnalytic.init();

	//set hit page view to analytic
	$dispatcher.listen(RouterEvents.AFTER_HANDLE_ROUTE, (pageData) => {

		if (pageData &&
				pageData.response &&
				(pageData.response.status >= 200 &&
				pageData.response.status < 300)) {

			fbPixelAnalytic.hitPageView(pageData);
		}
	});
}

Version 1.0 notice

Since version 1.0 you need to additionally call a load() method. The later you call this method the better. If you don't have a specific point in your app where you know that the page has finished loading you can call the load() method immediatelly after init() method

if ($window.isClient()) {

	// insert analytic script to page and initialization analytic
	fbPixelAnalytic.init();
	fbPixelAnalytic.load();

	// ...

Dependencies

If you are looking more details, you should follow this links: [https://github.com/seznam/IMA.js-plugins/tree/master/packages/plugin-analytic](https://github.com/seznam/IMA.js-plugins/tree/master/packages/plugin-analytic, https://github.com/seznam/IMA.js-plugins/tree/master/packages/plugin-script-loader

You can’t perform that action at this time.