Will a custom dimension's value be applied to the pageview of the page in which the ga('set') script appears










0














I am trying to implement a Google Analytics user-level custom dimension on a site.



I have read here that the code to do this looks something like this:



ga('set', 'dimension2', value );


If I include that script in page X, will the hit for page X's page-view include that dimension/value? Or will it only apply to future hits that that user initiates?










share|improve this question


























    0














    I am trying to implement a Google Analytics user-level custom dimension on a site.



    I have read here that the code to do this looks something like this:



    ga('set', 'dimension2', value );


    If I include that script in page X, will the hit for page X's page-view include that dimension/value? Or will it only apply to future hits that that user initiates?










    share|improve this question
























      0












      0








      0







      I am trying to implement a Google Analytics user-level custom dimension on a site.



      I have read here that the code to do this looks something like this:



      ga('set', 'dimension2', value );


      If I include that script in page X, will the hit for page X's page-view include that dimension/value? Or will it only apply to future hits that that user initiates?










      share|improve this question













      I am trying to implement a Google Analytics user-level custom dimension on a site.



      I have read here that the code to do this looks something like this:



      ga('set', 'dimension2', value );


      If I include that script in page X, will the hit for page X's page-view include that dimension/value? Or will it only apply to future hits that that user initiates?







      google-analytics






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 23:16









      WillDWillD

      449114




      449114






















          1 Answer
          1






          active

          oldest

          votes


















          1














          Since you're setting a user level scoped CD, it will apply to all previous hits in the session as well.



          I'd recommend you do the ga('set') before you perform ga('send'), this way you utilize the pageview hit to set this CD, not the next hit.



          Edit:
          Your regular implementation looks like this:



          <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m))(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          ga('create', 'UA-XXXXX-Y', 'auto');

          ga('set', ...); //do you sets here

          ga('send', 'pageview'); //this is the send
          </script>
          <!-- End Google Analytics -->


          Alternatively, you can just run this and just do "set" and "send" separately, though you'd want to execute the set/send very close to when you load the page:



           <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m)function()).push(arguments),i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          )(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          **//removed ga(send) stuff**

          </script>
          <!-- End Google Analytics -->


          To verify, use dev tools, look at your networks tab. Search/filter for "collect" you'll see the calls made to GA. Look for the parameters for the call, specificall cd1, cd2, cd3 etc...look for the cd# that's the same index as the cd you've set. Verify the data there is correct.
          enter image description here






          share|improve this answer






















          • Forgive me I am a little new to GA... I am not manually performing a ga('send'...). I thought that this was performed automatically by the analitics.js when a new page was loaded? If I manually call ga('send') on a pageview won't it double-count the page view?
            – WillD
            Nov 13 '18 at 16:53










          • the ga('send') is part of the implementation code, you can just take it out. You can also choose to send a non-interaction event as well if that makes it easier for you to implement.
            – XTOTHEL
            Nov 13 '18 at 17:01










          • Last question: is there anyway that you know of to test if this is working? Data doesn't seem to propagate to the GA dashboard for many hours. Can I test to see if it the dimension data is coming in correctly somehow, without having to wait til tomorrow?
            – WillD
            Nov 13 '18 at 17:18






          • 1




            updated answer with screenshot showing chrome dev tools
            – XTOTHEL
            Nov 13 '18 at 17:28










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271484%2fwill-a-custom-dimensions-value-be-applied-to-the-pageview-of-the-page-in-which%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Since you're setting a user level scoped CD, it will apply to all previous hits in the session as well.



          I'd recommend you do the ga('set') before you perform ga('send'), this way you utilize the pageview hit to set this CD, not the next hit.



          Edit:
          Your regular implementation looks like this:



          <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m))(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          ga('create', 'UA-XXXXX-Y', 'auto');

          ga('set', ...); //do you sets here

          ga('send', 'pageview'); //this is the send
          </script>
          <!-- End Google Analytics -->


          Alternatively, you can just run this and just do "set" and "send" separately, though you'd want to execute the set/send very close to when you load the page:



           <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m)function()).push(arguments),i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          )(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          **//removed ga(send) stuff**

          </script>
          <!-- End Google Analytics -->


          To verify, use dev tools, look at your networks tab. Search/filter for "collect" you'll see the calls made to GA. Look for the parameters for the call, specificall cd1, cd2, cd3 etc...look for the cd# that's the same index as the cd you've set. Verify the data there is correct.
          enter image description here






          share|improve this answer






















          • Forgive me I am a little new to GA... I am not manually performing a ga('send'...). I thought that this was performed automatically by the analitics.js when a new page was loaded? If I manually call ga('send') on a pageview won't it double-count the page view?
            – WillD
            Nov 13 '18 at 16:53










          • the ga('send') is part of the implementation code, you can just take it out. You can also choose to send a non-interaction event as well if that makes it easier for you to implement.
            – XTOTHEL
            Nov 13 '18 at 17:01










          • Last question: is there anyway that you know of to test if this is working? Data doesn't seem to propagate to the GA dashboard for many hours. Can I test to see if it the dimension data is coming in correctly somehow, without having to wait til tomorrow?
            – WillD
            Nov 13 '18 at 17:18






          • 1




            updated answer with screenshot showing chrome dev tools
            – XTOTHEL
            Nov 13 '18 at 17:28















          1














          Since you're setting a user level scoped CD, it will apply to all previous hits in the session as well.



          I'd recommend you do the ga('set') before you perform ga('send'), this way you utilize the pageview hit to set this CD, not the next hit.



          Edit:
          Your regular implementation looks like this:



          <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m))(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          ga('create', 'UA-XXXXX-Y', 'auto');

          ga('set', ...); //do you sets here

          ga('send', 'pageview'); //this is the send
          </script>
          <!-- End Google Analytics -->


          Alternatively, you can just run this and just do "set" and "send" separately, though you'd want to execute the set/send very close to when you load the page:



           <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m)function()).push(arguments),i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          )(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          **//removed ga(send) stuff**

          </script>
          <!-- End Google Analytics -->


          To verify, use dev tools, look at your networks tab. Search/filter for "collect" you'll see the calls made to GA. Look for the parameters for the call, specificall cd1, cd2, cd3 etc...look for the cd# that's the same index as the cd you've set. Verify the data there is correct.
          enter image description here






          share|improve this answer






















          • Forgive me I am a little new to GA... I am not manually performing a ga('send'...). I thought that this was performed automatically by the analitics.js when a new page was loaded? If I manually call ga('send') on a pageview won't it double-count the page view?
            – WillD
            Nov 13 '18 at 16:53










          • the ga('send') is part of the implementation code, you can just take it out. You can also choose to send a non-interaction event as well if that makes it easier for you to implement.
            – XTOTHEL
            Nov 13 '18 at 17:01










          • Last question: is there anyway that you know of to test if this is working? Data doesn't seem to propagate to the GA dashboard for many hours. Can I test to see if it the dimension data is coming in correctly somehow, without having to wait til tomorrow?
            – WillD
            Nov 13 '18 at 17:18






          • 1




            updated answer with screenshot showing chrome dev tools
            – XTOTHEL
            Nov 13 '18 at 17:28













          1












          1








          1






          Since you're setting a user level scoped CD, it will apply to all previous hits in the session as well.



          I'd recommend you do the ga('set') before you perform ga('send'), this way you utilize the pageview hit to set this CD, not the next hit.



          Edit:
          Your regular implementation looks like this:



          <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m))(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          ga('create', 'UA-XXXXX-Y', 'auto');

          ga('set', ...); //do you sets here

          ga('send', 'pageview'); //this is the send
          </script>
          <!-- End Google Analytics -->


          Alternatively, you can just run this and just do "set" and "send" separately, though you'd want to execute the set/send very close to when you load the page:



           <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m)function()).push(arguments),i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          )(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          **//removed ga(send) stuff**

          </script>
          <!-- End Google Analytics -->


          To verify, use dev tools, look at your networks tab. Search/filter for "collect" you'll see the calls made to GA. Look for the parameters for the call, specificall cd1, cd2, cd3 etc...look for the cd# that's the same index as the cd you've set. Verify the data there is correct.
          enter image description here






          share|improve this answer














          Since you're setting a user level scoped CD, it will apply to all previous hits in the session as well.



          I'd recommend you do the ga('set') before you perform ga('send'), this way you utilize the pageview hit to set this CD, not the next hit.



          Edit:
          Your regular implementation looks like this:



          <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m))(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          ga('create', 'UA-XXXXX-Y', 'auto');

          ga('set', ...); //do you sets here

          ga('send', 'pageview'); //this is the send
          </script>
          <!-- End Google Analytics -->


          Alternatively, you can just run this and just do "set" and "send" separately, though you'd want to execute the set/send very close to when you load the page:



           <!-- Google Analytics -->
          <script>
          (function(i,s,o,g,r,a,m)function()).push(arguments),i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          )(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

          **//removed ga(send) stuff**

          </script>
          <!-- End Google Analytics -->


          To verify, use dev tools, look at your networks tab. Search/filter for "collect" you'll see the calls made to GA. Look for the parameters for the call, specificall cd1, cd2, cd3 etc...look for the cd# that's the same index as the cd you've set. Verify the data there is correct.
          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 17:27

























          answered Nov 13 '18 at 5:05









          XTOTHELXTOTHEL

          1,9751210




          1,9751210











          • Forgive me I am a little new to GA... I am not manually performing a ga('send'...). I thought that this was performed automatically by the analitics.js when a new page was loaded? If I manually call ga('send') on a pageview won't it double-count the page view?
            – WillD
            Nov 13 '18 at 16:53










          • the ga('send') is part of the implementation code, you can just take it out. You can also choose to send a non-interaction event as well if that makes it easier for you to implement.
            – XTOTHEL
            Nov 13 '18 at 17:01










          • Last question: is there anyway that you know of to test if this is working? Data doesn't seem to propagate to the GA dashboard for many hours. Can I test to see if it the dimension data is coming in correctly somehow, without having to wait til tomorrow?
            – WillD
            Nov 13 '18 at 17:18






          • 1




            updated answer with screenshot showing chrome dev tools
            – XTOTHEL
            Nov 13 '18 at 17:28
















          • Forgive me I am a little new to GA... I am not manually performing a ga('send'...). I thought that this was performed automatically by the analitics.js when a new page was loaded? If I manually call ga('send') on a pageview won't it double-count the page view?
            – WillD
            Nov 13 '18 at 16:53










          • the ga('send') is part of the implementation code, you can just take it out. You can also choose to send a non-interaction event as well if that makes it easier for you to implement.
            – XTOTHEL
            Nov 13 '18 at 17:01










          • Last question: is there anyway that you know of to test if this is working? Data doesn't seem to propagate to the GA dashboard for many hours. Can I test to see if it the dimension data is coming in correctly somehow, without having to wait til tomorrow?
            – WillD
            Nov 13 '18 at 17:18






          • 1




            updated answer with screenshot showing chrome dev tools
            – XTOTHEL
            Nov 13 '18 at 17:28















          Forgive me I am a little new to GA... I am not manually performing a ga('send'...). I thought that this was performed automatically by the analitics.js when a new page was loaded? If I manually call ga('send') on a pageview won't it double-count the page view?
          – WillD
          Nov 13 '18 at 16:53




          Forgive me I am a little new to GA... I am not manually performing a ga('send'...). I thought that this was performed automatically by the analitics.js when a new page was loaded? If I manually call ga('send') on a pageview won't it double-count the page view?
          – WillD
          Nov 13 '18 at 16:53












          the ga('send') is part of the implementation code, you can just take it out. You can also choose to send a non-interaction event as well if that makes it easier for you to implement.
          – XTOTHEL
          Nov 13 '18 at 17:01




          the ga('send') is part of the implementation code, you can just take it out. You can also choose to send a non-interaction event as well if that makes it easier for you to implement.
          – XTOTHEL
          Nov 13 '18 at 17:01












          Last question: is there anyway that you know of to test if this is working? Data doesn't seem to propagate to the GA dashboard for many hours. Can I test to see if it the dimension data is coming in correctly somehow, without having to wait til tomorrow?
          – WillD
          Nov 13 '18 at 17:18




          Last question: is there anyway that you know of to test if this is working? Data doesn't seem to propagate to the GA dashboard for many hours. Can I test to see if it the dimension data is coming in correctly somehow, without having to wait til tomorrow?
          – WillD
          Nov 13 '18 at 17:18




          1




          1




          updated answer with screenshot showing chrome dev tools
          – XTOTHEL
          Nov 13 '18 at 17:28




          updated answer with screenshot showing chrome dev tools
          – XTOTHEL
          Nov 13 '18 at 17:28

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271484%2fwill-a-custom-dimensions-value-be-applied-to-the-pageview-of-the-page-in-which%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3