We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Quote from: ZAP at Dec 07, 2007, 06:05 PM

    .. and then create a TV called GAgoal where you enter a value when you want that specific page to be tracked?

    @ZAP: SammyR wants Google Analytics to track the same URL differently depending on the state of the form, so setting a TV for the page will always return the same thing. But eForm functions sounds exactly like what I was thinking of for dynamically setting a placeholder to represent the pagename that we send to GA - thanks for the lead.
      Mike Schell
      Lead Developer, MODX Cloud
      Email: [email protected]
      GitHub: https://github.com/netProphET/
      Twitter: @mkschell
      • 33372
      • 1,611 Posts
      Quote from: netProphET at Dec 07, 2007, 06:18 PM

      @ZAP: SammyR wants Google Analytics to track the same URL differently depending on the state of the form, so setting a TV for the page will always return the same thing. But eForm functions sounds exactly like what I was thinking of for dynamically setting a placeholder to represent the pagename that we send to GA - thanks for the lead.
      It might be easier to use a gotoID in eForm (instead of a thank you chunk) and TVs, though. Especially if he wants to track other specific pages that don’t have anything to do with eForm. But either way would work (or both, really - you could just put both the TV and placeholder in your template).
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 25124
        • 54 Posts
        Quote from: ZAP at Dec 07, 2007, 06:23 PM

        Quote from: netProphET at Dec 07, 2007, 06:18 PM

        @ZAP: SammyR wants Google Analytics to track the same URL differently depending on the state of the form, so setting a TV for the page will always return the same thing. But eForm functions sounds exactly like what I was thinking of for dynamically setting a placeholder to represent the pagename that we send to GA - thanks for the lead.
        It might be easier to use a gotoID in eForm (instead of a thank you chunk) and TVs, though. Especially if he wants to track other specific pages that don’t have anything to do with eForm. But either way would work (or both, really - you could just put both the TV and placeholder in your template).

        Hi Zap,

        The form passes variables to the &thankyou bit, so people can check details are correct. I’m still looking for a solution for this.
        If anyone could shed some more light, it would be appreciated.

        S

          • 33372
          • 1,611 Posts
          Have you tried using a gotoID instead of a thankyou chunk? If you do that, your thank you page will be a completely different document, so you can add your GA goal-tracking code to it and it will definitely be tracked separately. I would think that would be the easiest way to do this, but I think that you can include goal code in your thankyou chunk as well (depending upon how you set up GA to recognize that the goal was completed).
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 29635
            • 361 Posts
            Just in case you haven’t thought of it, you should probably be doing all this testing on a test profile, not your main profile. You can’t get rid of info once it’s there, so it’s nice to dirty up a profile you don’t actually use. Otherwise you get a bunch of bad data messing up your averages and graphs.

            Not super on topic, but hopefully it saves you some annoyance.
              Need MODx Ecommerce? Try FoxyCart!
              • 25124
              • 54 Posts
              Quote from: ZAP at Feb 21, 2008, 08:01 PM

              Have you tried using a gotoID instead of a thankyou chunk? If you do that, your thank you page will be a completely different document, so you can add your GA goal-tracking code to it and it will definitely be tracked separately. I would think that would be the easiest way to do this, but I think that you can include goal code in your thankyou chunk as well (depending upon how you set up GA to recognize that the goal was completed).

              Hi Zap,

              Sorry to bring up and old thread, but I never got this working and really need to get this resolved.

              I understand what you are saying above with a gotoid rather than &thankyou - however, on the &thankyou page, the information that the enquirer filled out is presented again in order for them to double-check that they made no mistakes with this. When I use a gotoid page and try to call up the information there is none to show.

              Any ideas?

              S
                • 33372
                • 1,611 Posts
                You can use an eForm event function to store the info in a session variable and then a snippet on the final page to set MODx placeholders for each of those and destroy the session var. I usually use the eFormOnBeforeMailSent event because it’s called whether or not &noemail is set. In that function you could assign each field of data that you need on the last page to the session var like so:

                $_SESSION['info']['thing1'] = $fields['thing1'];
                $_SESSION['info']['thing2'] = $fields['thing2'];
                


                The snippet on your final page could include something like:
                $modx->setPlaceholder('thing1', $_SESSION['info']['thing1']);
                $modx->setPlaceholder('thing2', $_SESSION['info']['thing2']);
                unset($_SESSION['info']);
                


                And then you can just use [+thing1+] and [+thing2+] in your page content.

                You could also just create a snippet that generates and displays the output from the session var without placeholders, of course (I just like placeholders).
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 25124
                  • 54 Posts
                  hi zap,

                  Thanks for your reply.

                  I’m already using the eFormOnBeforeMailSent to populate a SQL database with the information that the user fills out. Is it possible to have both of these working at the same time?

                  Regards

                  S
                    • 33372
                    • 1,611 Posts
                    Sure - you can just add this code to your existing function.
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 25124
                      • 54 Posts
                      Quote from: ZAP at Jun 15, 2008, 03:40 PM

                      Sure - you can just add this code to your existing function.
                      Hi Zap,

                      Here is my code for eForm2db (which is what is called here &eFormOnBeforeMailSent=`eForm2db`)


                      <?php
                      function eForm2db( &$fields )
                      	{
                      		global $modx;
                      $fields['remote_addr']=$_SERVER['REMOTE_ADDR'];
                      $fields['remote_host']=$_SERVER['REMOTE_HOST'];
                      $fields['user_agent']=$_SERVER['HTTP_USER_AGENT'];
                      		// Init our array
                      		$dbTable = array();
                      $dbTable['Title'] = $modx->db->escape($fields['Title']);
                      $dbTable['Name'] = $modx->db->escape($fields['Name']);
                      $dbTable['Company'] = $modx->db->escape($fields['Company']);
                      $dbTable['Address'] = $modx->db->escape($fields['Address']);
                      $dbTable['Telephone'] = $modx->db->escape($fields['Telephone']);
                      $dbTable['Fax'] = $modx->db->escape($fields['Fax']);
                      $dbTable['email'] = $modx->db->escape($fields['email']);
                      $dbTable['Quality'] = $modx->db->escape($fields['Quality']);
                      $dbTable['Content'] = $modx->db->escape($fields['Content']);
                      $dbTable['Request'] = $modx->db->escape($fields['Request']);
                      $dbTable['Metal'] = $modx->db->escape($fields['Metal']);
                      		$dbTable['IP'] = $_SERVER['REMOTE_ADDR'];
                      		$dbTable['Host'] = $_SERVER['REMOTE_HOST'];
                      		$dbTable['Agent'] = $_SERVER['HTTP_USER_AGENT'];
                      		// Run the db insert query
                      		$dbQuery = $modx->db->insert($dbTable, 'feedback' );
                      		return true;
                      	}
                      ?>
                      


                      Can you please give me a simple 1 2 3 as to how I can accomplish what you are saying. If you get me on the right road, I should have no problems rolling it out.

                      Thanks again, S