The initialization of dataLayer

This code snippet initializes and updates the dataLayer, a JavaScript object commonly used in analytics and tag management systems like Google Tag Manager (GTM). The dataLayer stores information about the page, content, and user interactions, which can then be used by analytics tools for tracking and reporting.

Here’s a detailed breakdown of what’s happening:


1. Initialization of window.dataLayer

The window.dataLayer array is initialized with a structured object containing metadata about the content, page, and other attributes. Here’s what’s included:

Content Information
  • content: Contains details about the article or content being displayed.
    • category: Specifies the content type (feature), with legacy metadata for Webtrends tracking.
    • article: Includes the article’s DOI (10.1038/d41586-019-03165-4).
    • attributes: Metadata about the CMS (core media), delivery platform (oscar), and copyright status (open: false).
    • contentInfo: Information about the article, such as:
      • title: "On the shoulders of giants"
      • publishedAt: Timestamp (1572998400, which corresponds to 2019-11-06).
      • documentType: "aplusplus"
    • journal: Specifies the journal (nature) with pcode, title, volume, and issue.
    • authorization: Indicates the user’s authorization status (status: true).
    • features: Lists features associated with the content (e.g., furtherReadingSection is false).
    • collection: Contains a collection ID (hddgebfbee).
Page Information
  • page: Describes the page’s category and attributes.
    • category: Specifies the page type (article).
    • attributes: Includes the page template (magazine mosaic) and feature flags (e.g., nature-oa-paywall is true).
    • search: Currently null.
Other Information
  • privacy: Empty object, likely for privacy-related data.
  • version: Version of the data structure (1.0.0).
  • product, session, user: Currently null.
  • backHalfContent: false.
  • country: Specifies the user’s country (GB for Great Britain).
  • hasBody: false.
  • uneditedManuscript: false.
  • twitterId: Array of Twitter IDs (["o3xnx", "o43y9", "o3ef7"]).

2. Updating window.dataLayer

The window.dataLayer.push() method adds additional data to the dataLayer:

  • ga4MeasurementId: The Google Analytics 4 (GA4) measurement ID (G-ERRNTNZ807).
  • ga360TrackingId: The Google Analytics 360 tracking ID (UA-71668177-1).
  • twitterId: Updated array of Twitter IDs (['3xnx', 'o43y9', 'o3ef7']).
  • ga4ServerUrl: The URL for GA4 server-side tracking (https://collect.nature.com).
  • imprint: Specifies the imprint (nature).
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值