ITsolutionWizard
asked on
xml, google script c#
I try to register the script below, and show on default.aspx
the codes look right but don't work to me. Please help.
the codes look right but don't work to me. Please help.
protected void Page_Load(object sender, EventArgs e)
{
string googleScript = string.Empty;
if (domainName.Contains("aaa.com"))
{
googleScript = "<script async src='https://www.googletagmanager.com/gtag/js?id=UA-923423499-4'></script>" +
"<script> window.dataLayer = window.dataLayer || []; " +
" function gtag(){ dataLayer.push(arguments); } " +
" gtag('js', new Date()); " +
" gtag('config', 'UA-923423499-4'); " +
"</script>";
}
if (googleScript != "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), googleScript,"",true);
}
}
//my goal is to add <script></script> on aspx webpage
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
have you tested it out? it worked for me.
as proposed