Enable User-ID tracking in Google Analytics for Xenforo

Trong hướng dẫn này mình sẽ hướng dẫn các bạn có thể sử dụng tính năng tracking User-ID của Google Analytics trên Xenforo. Về tính năng, công dụng của tracking theo User-ID thì ae chịu khó search GG có hết nhé, nếu có serial bài nào về User-ID mình sẽ cập nhật lại bài viết này sau.


Hướng dẫn bật tính năng User-ID tracking trên Xenforo

B1: Tạo User-ID View mới (xem hướng dẫn tại: https://support.google.com/analytics/answer/3123666?hl=vi)

B2: Login Xenforo Admin -> Appearance -> Templates -> tìm template name: google_analytics

Trong template này tìm đoạn

<xf:if is="$xf.options.googleAnalyticsAnonymize"> 'anonymize_ip': true, </xf:if>

Thêm vào ngay sau:

<xf:if is="{$xf.visitor.user_id}"> 'user_id' : '{$xf.visitor.username}', </xf:if>

Hết tút, ae có thể test lại trên Google Analytics, view-source để xem code đã hoạt động ngon chưa :)

Tài liệu tham khảo:

  1. https://support.google.com/analytics/answer/3123666?hl=en
  2. https://developers.google.com/analytics/devguides/collection/gtagjs/cookies-user-id
  3. https://xenforo.com/community/resources/conditional-statements-for-xenforo-2.5795/

Đăng nhận xét

-->