Google Analytics objectives support

7 replies [Last post]
djoulle
User offline. Last seen 7 weeks 3 days ago. Offline
Joined: 01/14/2010

Hi Leigthon,

To track each membership plans as objectives in GA, a different "thank you" landing page is requiered.

What would be the best way to achieve this, would this work ?

1149

$m_plan->return_url = url('membership/thankyou/'. $mpid, array('absolute' => TRUE)); 

Thanks for your help

Julien

wildkatana
User offline. Last seen 21 min 13 sec ago. Offline
Joined: 06/03/2009
Julien, You could set

Julien,
You could set different Thank You pages for each membership plan, and put the applicable tracking code on each one. Or you could put a switch statement in the thankyou page .tpl file and put in the correct code depending on what plan was purchased.

Sincerely,
Leighton Whiting

djoulle
User offline. Last seen 7 weeks 3 days ago. Offline
Joined: 01/14/2010
Hi Leigthon, The problem to

Hi Leigthon,

The problem to use a custom thank you page is that autologin will be disabled.

Objectives can't be tracked with a triger in a page as far as I know, they must be set up in the Google analytics account with a different landing page for each objective (can also be the same page with different parameters).

I did try 

membership/thankyou?mid=' . $m_plan->mpid

but Paypal encode the return url to 

membership/thankyou%3fmid%3d1

which doesn't work, but that must be a Paypal issue

I did try

membership/thankyou/' . $m_plan->mpid 

But can't make it work neither... even adding thankyou/1 and thankyou/2 pages in the hook menu

Thank you for your help

Julien

wildkatana
User offline. Last seen 21 min 13 sec ago. Offline
Joined: 06/03/2009
Julien, I will have to look

Julien,
I will have to look into the Auto Login thing some more, it works on my sites whether I use the default Thank-You page or not, so there must be something I'm overlooking. I'll do some debugging and get back to you on this.

Sincerely,
Leighton Whiting

djoulle
User offline. Last seen 7 weeks 3 days ago. Offline
Joined: 01/14/2010
Hi Leigthon, Autologin isn't

Hi Leigthon,

Autologin isn't working with custom thank you pages on my side, the user account isn't created so it can't be granted with a role and loged, despite the IPN seems correct with the custom var and web_accept.

To have a temporary solution, why is it not possible to add thankyou/1 and thankyou/2 pages in the hook menu and to use "membership/thankyou/" . $m_plan->mpid" as return url ?

Thanks for your help

Julien

wildkatana
User offline. Last seen 21 min 13 sec ago. Offline
Joined: 06/03/2009
Julien, This is something

Julien, This is something that has been fixed in Membership Suite 6 that I'm working on now, because the whole Thank-You page system has been reworked. If you want a temporary solution, you can do the following:

In ms_membership.module, make the following changes:

Lines 1203, 1219, 1230, and 1238 change:

$content = theme('ms_membership_thankyou_page', 0, 1, 0, $user);

To:

$content = theme('ms_membership_thankyou_page', 0, 1, 0, $user, $m_plan->mpid);

Basically just add the $m_plan->mpid to the end of the arguments, leaving the other arguments the same. We care going to pass in the plan id to the thankyou page template.

Line 1507, change:

'arguments' => array('isModify' => NULL, 'autoLogin' => NULL, 'isUpgrade' => NULL, 'account' => NULL),

To:

'arguments' => array('isModify' => NULL, 'autoLogin' => NULL, 'isUpgrade' => NULL, 'account' => NULL, 'planId' => NULL),

We are adding the planId parameter to the theme function

Then in the ms_membership-thankyou.tpl.php file, you can add a switch statement to the bottom that will insert the correct code depending on the Membership Plan ID:

switch ($planId) {

case 1: // Add the Code for Membership Plan 1

?>

<script>GOOGLE CODE FOR PLAN 1</script>

<?

break;

case 2: // Add the Code for Membership Plan 2

?>

<script>GOOGLE CODE FOR PLAN 1</script>

<?

break;

}

I haven't tested this, but it should work. In the new version, each plan will have a variable for a custom thankyou page, which you can use to track with Google Analytics much easier. Also, the Auto Login feature is being revamped and is working with any page.

Sincerely,

Leighton Whiting

 

djoulle
User offline. Last seen 7 weeks 3 days ago. Offline
Joined: 01/14/2010
Hi Leigthon, Thank you very

Hi Leigthon,

Thank you very much for your support ! But as objective tracking can only be achieved by adding different landing pages in the Google Analytics account and can't be done by adding a javascript code on a page, as far as I know, I had to do it by adding manually thankyou/1 and thankyou/2 pages in the hook menu and to use
"membership/thankyou/" . $m_plan->mpid" as return url in the membership module.
It wasn't working before because I didn't disbaled and enabled the module to refresh the hook menu pages, but now everything works fine, membership/thankyou1 and membership/thankyou2 are correctly tracked as objetives.

Thanks

Julien

wildkatana
User offline. Last seen 21 min 13 sec ago. Offline
Joined: 06/03/2009
Julien, Thanks for sharing

Julien,
Thanks for sharing your solution. This is a good fix for Membership Suite 5.x, but once 6.x is released, you will be able to simply set different thank-you pages for each plan in a much easier way.

Sincerely,
Leighton Whiting