গোপনীয়তা এবং বার্তাপ্রেরণ জাভাস্ক্রিপ্ট API নমুনা

আপনার ট্রাফিকের একটি এলোমেলো নমুনা বার্তা দেখান

<script>
  // Make sure that the googlefc property exists on the window.
  window.googlefc = window.googlefc || {};
  // To guarantee functionality, this must go before the tag on the page.
  googlefc.controlledMessagingFunction = (message) => {
    // Show the message to 10% of traffic.
    var percentageToShowTo = 10;

    // Pick a random number between 0 and 100.
    var rand = Math.random() * 100;

    if (rand <= percentageToShowTo) {
      message.proceed(true);
    } else {
      message.proceed(false);
    }
  };
</script>

গ্রাহকদের বার্তা দেখাবেন না

(অনুমান করা হয় যে আপনার কাছে একটি ফাংশন রয়েছে যার তথ্য একজন ব্যবহারকারী গ্রাহক কিনা)

<script>
  // Make sure that the googlefc property exists on the window.
  window.googlefc = window.googlefc || {};
  // To guarantee functionality, this must go before the tag on the page.
  googlefc.controlledMessagingFunction = (message) => {
    // checkSubscriptionStatus() is an example of a function that may exist
    // in your codebase that resolves a promise with true or false depending on
    // whether the user on the page is a subscriber.
    checkSubscriptionStatus().then(
      function (isSubscriber) {
        // Do not show the message if a user is a subscriber.
        if (isSubscriber) {
          message.proceed(false);
        } else {
          message.proceed(true);
        }
      }
    );
  }
</script>

আপনার হোম পেজ ছাড়া সব জায়গায় বার্তা দেখান

<script>
  // Make sure that the googlefc property exists on the window.
  window.googlefc = window.googlefc || {};
  // To guarantee functionality, this must go before the tag on the page.
  googlefc.controlledMessagingFunction = (message) => {
    var pathname = location.pathname;

    // This assumes other pages on your site are differentiated with a different
    // path. `location.href` can also be used if more information is needed to
    // differentiate between the home page and other pages on the site.
    if (pathname.length > 1) {
      message.proceed(true);
    } else {
      message.proceed(false);
    }
  };
</script>

নির্দিষ্ট সংখ্যক পেজভিউয়ের পরেই বার্তাটি দেখান

(অনুমান করে যে আপনার নিজের কুকি বা পৃষ্ঠা দর্শনের সংখ্যা ট্র্যাক করার জন্য অন্য ব্যবস্থা আছে)

<script>
  // Make sure that the googlefc property exists on the window.
  window.googlefc = window.googlefc || {};
  // To guarantee functionality, this must go before the tag on the page.
  googlefc.controlledMessagingFunction = (message) => {
    // How many pageviews before the message is shown.
    var freePageviewsLimit = 3;

    // Check how many pages the user has seen.
    var pagesViewed = getPagesViewed();

    // Show the message if the user has seen more pages than the free limit.
    if (pagesViewed >= freePageviewsLimit) {
      message.proceed(true);
    } else {
      message.proceed(false);
    }
  };
</script>

নিউজ ট্যাগিং গাইড (NTG) এর সাথে Google Analytics-এ অনুমতি-বিজ্ঞাপন এবং বিজ্ঞাপন ব্লকিং ব্যবহারকারীদের সাথে সম্পর্কিত ইভেন্টগুলি ট্র্যাক করুন

সঠিক অ্যাকাউন্ট ট্র্যাকিং আইডি দিয়ে UA-xxxxxxxxxx-x প্রতিস্থাপন করুন।

নিউজ ট্যাগিং গাইড সম্পর্কে আরও তথ্য এখানে পাওয়া যাবে।

<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-xxxxxxxxx-x', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->

<script>
  // Make sure that the googlefc property exists on the window.
  window.googlefc = window.googlefc || {};
  googlefc.callbackQueue = googlefc.callbackQueue || [];
  googlefc.callbackQueue.push({
    'AD_BLOCK_DATA_READY': function() {
      switch (googlefc.getAdBlockerStatus()) {
        case googlefc.AdBlockerStatusEnum.EXTENSION_LEVEL_AD_BLOCKER:
        case googlefc.AdBlockerStatusEnum.NETWORK_LEVEL_AD_BLOCKER:
          ga('send', 'event', {
            eventCategory: 'NTG adblock',
            eventAction: 'detected',
            eventLabel: '<page url>',
            nonInteraction: true
          });
          break;
      }
      switch (googlefc.getAllowAdsStatus()) {
        case googlefc.AllowAdsStatusEnum.ADS_ALLOWED:
          ga('send', 'event', {
            eventCategory: 'NTG adblock',
            eventAction: 'allow-ads',
            eventLabel: '<page url>',
            nonInteraction: true
          });
          break;
      }
   }});
</script>

ব্যবহারকারীদের বিজ্ঞাপন ব্লকিং ব্যবহার নির্ধারণ করতে Google Analytics-এ ইভেন্ট ট্র্যাক করুন

কত শতাংশ ব্যবহারকারী নেটওয়ার্ক-লেভেল অ্যাড ব্লকার, এক্সটেনশন-লেভেল অ্যাড ব্লকার বা কোনও অ্যাড ব্লকার ব্যবহার করছেন তা নির্ধারণ করতে ব্যবহার করা যেতে পারে।

সঠিক অ্যাকাউন্ট ট্র্যাকিং আইডি দিয়ে UA-xxxxxxxxxx-x প্রতিস্থাপন করুন।

বিশ্লেষণ সম্পর্কে আরও তথ্যের জন্য Google Analytics ডক্স দেখুন।

<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-xxxxxxxxx-x', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->

<script>
  // Make sure that the googlefc property exists on the window.
  window.googlefc = window.googlefc || {};
  googlefc.callbackQueue = googlefc.callbackQueue || [];
  googlefc.callbackQueue.push({
    'AD_BLOCK_DATA_READY': function() {
      var analyticsData = {
          hitType: 'event',
          eventCategory: 'Funding Choices',
          eventAction: 'Ad Blocking Type'
        };
      switch (googlefc.getAdBlockerStatus()) {
        case googlefc.AdBlockerStatusEnum.EXTENSION_LEVEL_AD_BLOCKER:
          analyticsData.eventLabel = 'EXTENSION_LEVEL_AD_BLOCKER';
          ga('send', analyticsData);
          break;
        case googlefc.AdBlockerStatusEnum.NETWORK_LEVEL_AD_BLOCKER:
          analyticsData.eventLabel = 'NETWORK_LEVEL_AD_BLOCKER';
          ga('send', analyticsData);
          break;
        case googlefc.AdBlockerStatusEnum.NO_AD_BLOCKER:
          analyticsData.eventLabel = 'NO_AD_BLOCKER';
          ga('send', analyticsData);
          break;
      }
   }});
</script>