4 Replies Latest reply on Mar 18, 2020 9:52 AM by Nagaprabhu K

    Getting Email Group Id into a URL in an email

    BFG 9000

      Hi All,

       

      I have a need to craft a link in an email that includes the EmailGroupID as a querystring parameter.

       

      How would I approach this?

       

       

      TTFN

       

      BFG

        • 1. Re: Getting Email Group Id into a URL in an email
          bkhayes

          Hi BFG 9000,

           

          I'm going to propose a manual solution. It may or may not be the best way to do this. The below steps will show you how to create a basic query string. After that it will show you how to use JavaScript on the landing page to capture that query string on the form. That way it will show up in the form submission data.

           

          1. Place your custom link into the e-mail "http://example.com?EmailGroupID=Newsletter"

          2. Add below script to your landing page with form right before ending </body> tag:

           

          <!-- jQuery 2.2.4.min.js -->

          <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>

           

          <!-- Get query string for EmailGroupID and place value into field EmailGroupID -->

          <script type="text/javascript">

          function getUrlQS(q, url) {

            var vars = [],

              hash;

            if (typeof url == 'undefined') {

              var url = window.location.search;

            }

            var hashes = url.slice(url.indexOf('?') + 1).split('&');

            for (var i = 0; i < hashes.length; i++) {

              hash = hashes[i].split('=');

              vars.push(hash[0]);

              vars[hash[0]] = hash[1];

            }

            var qs = (typeof vars[q] !== 'undefined') ? decodeURIComponent(vars[q]) : '';

            return qs;

          }

          var queries = ['EmailGroupID'];

          for (var i = 0; i < queries.length; i++) {

            if ($('input[name=' + queries[i] + ']').length) {

              $('input[name=' + queries[i] + ']').val(getUrlQS(queries[i]));

            }

          }

          </script>

           

          3. Create a hidden field on the form called "EmailGroupID" with the HTML name "EmailGroupID".

          4. Run a test form submit with query string in URL.

          5. All done, should now see the result in form submission data under EmailGroupID field.

          • 2. Re: Getting Email Group Id into a URL in an email
            BFG 9000

            Thanks bkhayes,

             

            I'm not sure I explained my question well enough.

             

            Looking at the example below - I need to work out how I can dynamically insert the '123'

            http://example.com?EmailGroupID=123

             

            If I wanted to insert the LastName from the recipient contact record, I could do this :-

             

            LastNamehttp://example.com?LastName=<span class="eloquaemail">LastName</span>

            or this :-

            http://example.com?LastName=~~eloqua..type--emailfield..syntax--LastName..innerText--LastName..encodeFor--url~~

             

            What I'm missing I guess, is a list of ALL possible dynamic items that can be inserted into an email.

            • 3. Re: Getting Email Group Id into a URL in an email
              bkhayes

              This is a great question. I get what you mean now thank you for clarifying!

               

              I have been looking around for this as well and have not found much on it.

               

              What is it that you are trying to do with the EmailGroupID=123 once you have it?

              • 4. Re: Getting Email Group Id into a URL in an email
                Nagaprabhu K

                Hi,

                 

                I had the same requirement. I need to pass the email group ID with my LP's vanity URL as a parameter. We'd found that the "Campaign ID" fieldmerge is what bringing the email group id.

                 

                The way we found is,

                -      Create a Blank HTML email

                -      Enter some text in the right pane.

                -      Select the text in the left pane

                -      Click Tools (left most pane) -> Hyperlinks (chain icon) -> Enable as hyperlink  -> Link type -> System Action -> Remove from Email Group

                -      On the right side you'll see the text is hyperlinked with href="s=~~eloqua..type--emailfield..syntax--siteid..encodeFor--url~~&elqc=~~eloqua..type--emailfield..syntax--campaignid..encodeFor--url~~&elqTrackId=" like this. We noticed campaignID here acts as email group id.

                 

                Hence used the same.

                 

                Hope this helps!

                Thanks,

                Ingram Micro MTs