How To Install Adwords Conversion Tracking with Amember 4 and Wordpress

Discussion in 'Installation' started by plannerguy, Apr 23, 2015.

  1. plannerguy

    plannerguy aMember Pro Customer

    Joined:
    Jul 13, 2012
    Messages:
    13
    Hi,
    I thought I would post this for everyone's benefit, since it took me a few steps to finally figure this out and get it working. Alexander at amember support provided most of theses steps.

    To get Adwords conversion tracking working with Amember, you'll want to trigger adwords once you've completed a sale. In amember 4, using Wordpress, and using amember's "Use Wordpress Theme" settings, you'll see that amember loads a file called "thanks.phtml" after a sale is completed and displays the final sale details.

    You don't want to edit the source file so you'll want to create your own copy of thanks.phtml that overrides the source file.
    If you're using Wordpress, then here are the steps:

    1) Overriding thanks.phtml

    a) Goto /mysite.com/amember/application/default/plugins/protect/wordpress/ . Create a folder that matches your Wordpress theme folder's name. For me, since I'm using the genesis framework with a subtheme, I created a folder called 'genesis' (ie: /mysite.com/amember/application/default/plugins/protect/wordpress/genesis/).

    b) Copy /mysite.com/amember/application/default/views/thanks.phtml to the folder in a). Now this thanks.phtml file will override the source file. If you upgrade amember, this file will not be affected by the upgrade.

    2) Installing the Tracking Code

    c) In Adwords, get your conversion tracking code in html format. Mine looked like this:
    <!-- Google Code for Sale Conversion Page -->
    <script type="text/javascript">
    /* <![CDATA[ */
    var google_conversion_id = xxxxxxx;
    var google_conversion_language = "en";
    var google_conversion_format = "3";
    var google_conversion_color = "ffffff";
    var google_conversion_label = "yyyyyyyyyyyyyyyyyyyyyy";
    var google_conversion_value = 97.00;
    var google_conversion_currency = "USD";
    var google_remarketing_only = false;
    /* ]]> */
    </script>
    <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
    </script>
    <noscript>
    <div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/xxxxxxxxx/?value=97.00&amp;currency_code=USD&amp;label=yyyyyyyyyyyyy&amp;guid=ON&amp;script=0"/>
    </div>
    </noscript>

    d) Since I have different products and they cost different values, I want adwords to be aware, so we'll edit the code above to incorporate the product cost. Changes in Red.

    <script type="text/javascript">
    /* <![CDATA[ */
    var google_conversion_id = xxxxxxxxx;
    var google_conversion_language = "en";
    var google_conversion_format = "3";
    var google_conversion_color = "ffffff";
    var google_conversion_label = "yyyyyyyyyyyyy";
    <?php
    if ($invoice->first_total) {
    echo "var google_conversion_value = ".$invoice->first_total.";".PHP_EOL;
    }
    ?>

    var google_conversion_currency = "USD";
    var google_remarketing_only = false;
    /* ]]> */
    </script>
    <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
    </script>
    <noscript>
    <div style="display:inline;">
    <img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/xxxxxxxxx/?value=<?php echo $invoice->first_total ?>&amp;currency_code=USD&amp;label=yyyyyyyyyyyyy&amp;guid=ON&amp;script=0"/>
    </div>
    </noscript>

    e) Paste the code above into your thanks.phtml file at the very top. Save.

    f) Test. In a new browser, google something to make your adwords ad come up. Click your ad, then make a test purchase (I set up a dummy product for testing that costs a penny, and use a special sign-up form for only that product). Once the transaction is done, you should land on the page mysite.com/amember/thanks?id=xxxxx0xxxxx .
    View that page's source code to ensure you see the adwords tracking code and it looks right. You can also use the Google Tag Assistant Chrome browser plugin to help you troubleshoot this page.

    Good luck!
    Michael
    alexander likes this.

Share This Page