Pass a Variable From Link into aWeber Form

by Jet
9 replies
I have an aweber form on my wordpress site.

I want to place links with certain variables across the web, such as www.mysite.com?ref=source1

Then, I want the "source1" to be automatically added to one of the fields on the aweber form on my WP site.

Even if the visitor went to the home page first and then went to my form page, I still want to carry that variable to the form page.

Any ideas how I can do this?

Thanks,

JH
#aweber #form #link #pass #variable
  • Profile picture of the author Ken Durham
    Originally Posted by Jet View Post

    I have an aweber form on my wordpress site.

    I want to place links with certain variables across the web, such as www.mysite.com?ref=source1

    Then, I want the "source1" to be automatically added to one of the fields on the aweber form on my WP site.

    Even if the visitor went to the home page first and then went to my form page, I still want to carry that variable to the form page.

    Any ideas how I can do this?

    Thanks,

    JH
    hire me?
    Signature

    yes, I am....

    {{ DiscussionBoard.errors[7693788].message }}
  • Profile picture of the author atinder
    here is a hint,
    you can either use wordpress query variables or cookies
    {{ DiscussionBoard.errors[7694500].message }}
    • Profile picture of the author Jet
      Originally Posted by atinder View Post

      here is a hint,
      you can either use wordpress query variables or cookies
      Thanks.

      How do I set it up though?

      JH
      {{ DiscussionBoard.errors[7694796].message }}
      • Profile picture of the author Brandon Tanner
        Very simple... only takes a little bit of PHP to do this.

        1) Add the following code to the very top of your home page...

        <?php
        session_start();
        $_SESSION['ref'] = $_GET['ref'];
        ?>


        What this does is grab the value of the query string in your hyperlink ("ref"), and then saves that value to a "session" (meaning that value will persist throughout all of the pages on your website, so long as the user stays on your site).

        2) Now add the following code to the very top of the page that your optin form is on...

        <?php
        session_start();
        $ref = $_SESSION['ref'];
        ?>


        What this does is grab the value of the saved "session" (ie the value of "ref") and saves it to a PHP variable named $ref.

        3) Now anywhere you want the value of "ref" to appear in your HTML code on the opt-in page, just do this --> <?php echo $ref; ?>

        For example, if you want the value to be passed to a "hidden field" in your Aweber code, then you would do something like this...

        <input type="hidden" name="ref" value="<?php echo $ref; ?>" />

        For more info @ setting up hidden fields in Aweber, see this.

        Any page on your site that contains PHP code will need to need to have .php extensions, of course. But that's pretty much all there is to it.

        Another alternative would be to pass the "ref" value through every single page of your site via GET or POST, but that would be a lot more work. Or as atinder and Michael mentioned, you could use cookies instead of sessions. But some users will have cookies blocked by default, so using "sessions" is probably your best bet for something like this.
        Signature

        {{ DiscussionBoard.errors[7694966].message }}
        • Profile picture of the author Jet
          Thanks a lot Brandon. Does this work for Wordpress as well? Should I paste it into the header file or somewhere else?

          JH
          {{ DiscussionBoard.errors[7696823].message }}
          • Profile picture of the author Brandon Tanner
            I don't use WordPress so I can't give you any WP-specific advice, but PHP code will work on any server that has PHP installed (which means virtually all webhost servers out there).

            You should paste the code from steps 1 & 2 at the very start of the page (before any other HTML code). And you should paste the code from step 3 inside the opt-in form code. Maybe someone who uses WP could chime in here and help you out with that.

            And don't forget to change your home page and opt-in form page to .php extensions, and you should be good to go!
            Signature

            {{ DiscussionBoard.errors[7699796].message }}
  • Profile picture of the author Michael71
    Get the variable from ?ref= via PHP and write it into a cookie.
    Signature

    HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
    ---
    Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu

    {{ DiscussionBoard.errors[7694908].message }}
  • Profile picture of the author SteveJohnson
    Is your Aweber form hard-coded into a template, or do you have it in a text widget? There are a lot of factors in play here that don't allow for an easy answer.

    If the form code is in a text widget, there isn't going to be an easy way to accomplish what you want, it will take some coding. I can lead you through it, but you'll need to be comfortable with editing theme files.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[7700103].message }}
  • Profile picture of the author Jet
    Thanks,

    The problem is, I can't enter PHP on a wordpress page.

    I tried to put the php echo code within a field from the aweber form, but it just ends up displaying the code within that field instead of the actual referrer.

    I can edit theme files.

    What should I do?

    Thanks,

    JH
    {{ DiscussionBoard.errors[7719883].message }}

Trending Topics