2

I have variables being passed as meta data in the head section:

<meta id="ctl00_BDMeta_UserEmail" name="DCSext.UserEmail" />
<meta id="ctl00_BDMeta_Username" name="DCSext.Username" />
<meta id="ctl00_BDMeta_PageTitle" name="DCSext.PageTitle" />
<meta id="ctl00_BDMeta_PageURL" name="DCSext.PageURL" />

How can I pass these variables into Universal Analytics via GTM?

Would I create new JavaScript variables and pass in the value using getelementbyid?

Then in GTM, create a new JavaScript Variable and enter the new variable new when I configure the variable with the global variable name?

1 Answer 1

1

You would need to create a "Custom Javascript" variable (not a "Javascript Variable" variable, as you are not supplying it with a globally declared JS variable).

The Custom JS variable would be used to capture the values you need, possibly based on the IDs you provide using getElementById (or jQuery). So something like this, in your Custom JS tag:

function(){
    // do pre-checks to see if meta tag exists
    return $('meta#ct100_BDMeta_UserEmail').attr("name");
}
Sign up to request clarification or add additional context in comments.

3 Comments

Hi Nyuen, is that all I need to declare as follows: 'code'function(){ // do pre-checks to see if meta tag exists return $('meta#ct100_BDMeta_UserEmail').attr("DCSext.UserEmail"); }'code'
Does the custom JS also pass the value at the same time or would I have to add the getElementById JavaScript line?
The custom JS is returning the name. How do I return the value into GA?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.