Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Facebook Pixel Code -->
- <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','//connect.facebook.net/en_US/fbevents.js');
- fbq('init', '12121212');
- fbq('track', 'PageView');
- var executeWhenReachedPagePercentage = function(percentage, callback) {
- if (typeof percentage !== 'number') {
- console.error(
- 'First parameter must be a number, got',
- typeof percentage,
- 'instead',
- );
- }
- if (typeof callback !== 'function') {
- console.error(
- 'Second parameter must be a function, got',
- typeof callback,
- 'instead',
- );
- }
- function getDocumentLength() {
- var D = document;
- return Math.max(
- D.body.scrollHeight, D.documentElement.scrollHeight,
- D.body.offsetHeight, D.documentElement.offsetHeight,
- D.body.clientHeight, D.documentElement.clientHeight
- )
- }
- function getWindowLength() {
- return window.innerHeight ||
- (document.documentElement || document.body).clientHeight;
- }
- function getScrollableLength() {
- if (getDocumentLength() > getWindowLength()) {
- return getDocumentLength() - getWindowLength();
- } else {
- return 0;
- }
- }
- var scrollableLength = getScrollableLength();
- window.addEventListener('resize', function(){
- scrollableLength = getScrollableLength();
- }, false)
- function getCurrentScrolledLengthPosition() {
- return window.pageYOffset ||
- (document.documentElement || document.body.parentNode || document.body).scrollTop;
- }
- function getPercentageScrolled() {
- if (scrollableLength == 0) {
- return 100;
- } else {
- return getCurrentScrolledLengthPosition() / scrollableLength * 100;
- }
- }
- var executeCallback = (function() {
- var wasExecuted = false;
- return function() {
- if (!wasExecuted && getPercentageScrolled() > percentage) {
- wasExecuted = true;
- callback();
- }
- };
- })();
- if (getDocumentLength() == 0 ||
- (getWindowLength()/getDocumentLength() * 100 >= percentage)) {
- callback();
- } else {
- window.addEventListener('scroll', executeCallback, false);
- }
- };executeWhenReachedPagePercentage(75, function() { fbq('track', 'ViewContent'); });
- </script>
- <noscript><img height='1' width='1' style='display:none' src='https://www.facebook.com/tr?id=12121212&ev=PageView&noscript=1' /></noscript>
- <!-- End Facebook Pixel Code -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement