0
Google 태그 관리자 데이터 레이어에 daysLeft 변수를 전달하려고하지만 작동하지 않습니다. 내가 이것을 사용하면;변수가 Google 태그 관리자의 데이터 레이어로 전달되지 않는 이유
var newname = 'daysLeft';
태그가 실행되지만 보고서에는 daysLeft로 표시됩니다. 태그를 발사하려고하면
var newname = daysLeft;
태그가 작동하지 않습니다.
<script type="text/javascript">
var today = new Date(); // Get todays date.
var bookedDate = new Date('June 29, 2014'); // Fill this with the date of the booking in this format - June 29, 2013.
var msPerDay = 24 * 60 * 60 * 1000 ; // Work out the number of milliseconds in a day.
var timeLeft = (bookedDate.getTime() - today.getTime()); // Booked date minus todays tate, returned in milliseconds.
var e_daysLeft = timeLeft/msPerDay; // Divide millieseconds left untill booking by the number of milliseconds in a day.
var daysLeft = Math.floor(e_daysLeft); // Round the total down to the nearest integer.
var newname = daysLeft;
dataLayer = [{'event' : 'newname' }];
</script> <!-- Google Tag Manager -->
<noscript><iframe height="0" src="//www.googletagmanager.com/ns.html?id="
style="display:none;visibility:hidden" width="0"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','');
</script> <!-- End Google Tag Manager -->