Created
April 11, 2021 04:13
-
-
Save cyberdev/31901e784289e0fc394fd8bc58a00b79 to your computer and use it in GitHub Desktop.
Add Google Tag Script Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addGoogleTrackingCode(trackingCode){ | |
var s = document.createElement("script"); | |
s.type = "text/javascript"; | |
s.src = "https://www.googletagmanager.com/gtag/js?id=" + trackingCode; | |
s.setAttribute('async',''); | |
$("head").append(s); | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', trackingCode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment