Jump to content

Need some PHP help


pod

Recommended Posts

Hello all - i am working on Google Analytics Goal tracking and i believe i have this working, still testing.

 

But as you know GA only allows you to track 20 goals. But we run specials where we have multiple plans in whmcs for the same service ie: shared hosting plan or vps plan etc. and we have more of those plans than goals available.

 

Being a c#/asp developer, i know very little about php, so this is where i am looking for someone who can whip up a small php function, that i will make available to the whmcs community for goal tracking.

 

What i need is a php function we can add to the complete.tpl file,

 

1) The function should accept a "pid" - product id

 

2) have a two dimensional array: $pidGoals[0][0], that we can initialize like:

$pidGoals[0][0] = 46; // pid

$pidGoals[0][1] = "vps"; //url text

$pidGoals[1][0] = 48;

$pidGoals[1][1] = "vps";

 

3) Next search the array $pidGoals for the matching pid and then return the url text.

 

 

Thanks in advance!

Link to comment
Share on other sites

$pidGoals will be a new 2 dimension array that I and other can use to map pid to specific goal urls for talking.

 

The $pidGoals will be manually configured by a user with their systems pid's and the url needed to be pushed to GA.

 

The idea is to instead of us pushing "/client/cart.php?a=complete&pid={$packageid}" which is 100% uniqure for every package, i want to be able to map simular packages with the same pid or some new identified to group them.

 

An examplem say you have 6 different vps packages split them up into groups of 2. Basically in each group you have 2 plan which could be the same item just different in price or some sort of freebee. I dont care about tracking all six plans seperately. I want to map the 2 pids to the same unique goal url that we will push to GA. This way we can have more goals available to us for tracking.

Link to comment
Share on other sites

I write PHP, but I don't completely understand what you are looking for... Give a detailed brief and I'll see what I can do !

 

I am not sure how much more detail i can give, so here it is again, ask me what you are not sure of. I just need a function that accept a product id as a parameter. In the function i need a to be able to initialize a 2 dimensional array that I can store a product id and in the second dimension some text.

Then i need the function to loop through the array looking to match the passed product id parameter to the first dimension of the array and return me that arrays second dimension value (the string text).

 

BTW: PM me and maybe we can chat over YIM or MSN?

 

What i need is a php function we can add to the complete.tpl file,

 

1) The function should accept a "pid" - product id

 

2) have a two dimensional array: $pidGoals[0][0], that we can initialize like:

$pidGoals[0][0] = 46; // pid

$pidGoals[0][1] = "vps"; //url text

$pidGoals[1][0] = 48;

$pidGoals[1][1] = "vps";

 

3) Next search the array $pidGoals for the matching pid and then return the url text.

Link to comment
Share on other sites

You're not explaining why you need a function to return the results of a apparently statically assigned array.. Theres really no need for that.

 

function get_values($pid) {
  return $pidGoals[$pid];
}

 

Would be the same thing as just calling $pidGoals[$pid] yourself. Where are the values for $pidGoals being defined? What is the purpose of using a function to do this?

Link to comment
Share on other sites

laszlo, thanks you pushed me in the right direction....

 

function get_values($pid)

{

$pidGoals[46] = "/vps1";

$pidGoals[48] = "/vps1";

$pidGoals[49] = "/vps3";

 

 

if (isset($pidGoals[$pid]))

return $pidGoals[$pid];

else

return "unknown";

 

 

}

 

 

Basically we will be using this function to map whmcs product id's for simular products to specfiic urls that we will push to GA for goal tracking.

 

Thanks for everyones help.

Link to comment
Share on other sites

  • 2 weeks later...

Is this solved now..? :P

 

To format your PHP code above and make it work:

 


function get_values($pid)
{
   // Configure the products
   $pidGoals[46] = "/vps1";
   $pidGoals[48] = "/vps1";
   $pidGoals[49] = "/vps3";
   // End configuration - Do not edit below

   // See if it exists, then return the result
   if(isset($pidGoals[$pid]))
   {
       return $pidGoals[$pid];
   } else {
       return false;
   }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated