一辈子只做好两件事,就可以变得很富有,投资长期有价值的事情,规避无效之事——查理芒格

Thu 30 Oct 2025
66 views

The “Provide new customer data” option in Google Ads (through GTM) is there so Google can know whether a purchase or lead came from a new customer or an existing one. Google asks for this because it helps improve your conversion tracking and makes your ads smarter — especially if your goal is to get new customers. By sharing this data (safely and in a privacy-friendly way), Google can give you more accurate reports and optimize your campaigns better.

So, let’s move forward together!  It’s the perfect time to set up advanced tracking and start collecting the right customer data. To achieve this, we’ll use a custom tracking method that ensures accuracy and efficiency. Don’t worry — we’ll provide you with a universal tracking code to handle this job seamlessly.

To begin, head over to Google Tag Manager (GTM), create a new tag, and select Custom HTML as the tag type. Then, configure it to fire on All Pages for complete and reliable tracking across your website.

<script>

(function() {

  var cookieName = 'customer_type';

  var cookieValueReturning = 'returning';

  var days = 180;




  function getCookie(name) {

    var value = document.cookie

      .split('; ')

      .find(function(row){ return row.indexOf(name + '=') === 0; });

    return value ? value.split('=')[1] : null;

  }




  function setCookie(name, value, days) {

    var d = new Date();

    d.setTime(d.getTime() + (days*24*60*60*1000));

    document.cookie = name + "=" + value + "; path=/; samesite=lax; expires=" + d.toUTCString();

  }




  function hasLocalStorageFlag() {

    try {

      return !!localStorage.getItem(cookieName);

    } catch(e) {

      return false;

    }

  }




  function setLocalStorageFlag() {

    try {

      localStorage.setItem(cookieName, cookieValueReturning);

    } catch(e) {}

  }




  var isReturning = !!getCookie(cookieName) || hasLocalStorageFlag();

  var type = isReturning ? 'returning' : 'new';




  setCookie(cookieName, cookieValueReturning, days);

  setLocalStorageFlag();




  window.dataLayer = window.dataLayer || [];

  window.dataLayer.push({

    event: 'customer_type_determined',

    customer_type: type

  });

})();

</script>

 

How does it work? Step by step:

  1. It checks if you’ve been here before 
    • The script looks for a little “note” saved in your browser (this is called a cookie or local storage) with the name customer_type. 
    • If it finds it, you are considered returning. 
    • If it doesn’t find it, you are considered new. 
  2. It saves your visit for next time 
    • If you’re new, it writes that “note” in your browser saying you’re a returning visitor next time. 
    • That “note” lasts for 180 days (about 6 months). 
  3. It tells Google Tag Manager (dataLayer) 
    • After deciding if you’re new or returning, the script sends that info into something called the dataLayer. 
    • Example:

{

  event: ‘customer_type_determined’,

  customer_type: ‘new’

}

or 

{

  event: ‘customer_type_determined’,

  customer_type: ‘returning’

}

 

Google Tag Manager (or Google Ads, Analytics, etc.) can then use this info for tracking, reporting, or advertising.

 

In plain words:

The code is like a doorman at a shop.

  • First time you come in: “Ah, you’re new!” (and it saves your info for next time). 
  • Next time you come back: “Welcome back, returning customer!” 
  • Then it whispers this info to Google so you can track in reports or show different ads.

Great! With this method, our Custom HTML tag setup is now complete. The next step is to run a preview in Google Tag Manager. Once the preview is active, you’ll be able to see the new interface where valuable insights about your customer type (new or returning) will appear. This helps ensure your tracking is working correctly and gives you clear visibility into your customer data.

本网站所有内容资源全部免费,将会持续更新在跨境电商运营中所有你遇到的问题,掌握本网站所有内容你即可无敌!

您也可以扫描左侧二维码关注我们的微信公众号,持续关注我们的动态,不管你是找工作以及自运营都将会让你受益匪浅。

Share it on social media

Ohab

我专注于数字营销、网络分析和转化跟踪,帮助企业通过数据驱动的策略和洞察力推动增长。
(0)

暂无评论

Leave a Reply

关注微信公众号

添加微信加入粉丝群

加入星球

关键词

热门文章

最新文章

分类