pod Posted August 29, 2010 Share Posted August 29, 2010 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! 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 29, 2010 Share Posted August 29, 2010 Where is $pidGoals coming from? 0 Quote Link to comment Share on other sites More sharing options...
pod Posted August 29, 2010 Author Share Posted August 29, 2010 $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. 0 Quote Link to comment Share on other sites More sharing options...
pod Posted August 31, 2010 Author Share Posted August 31, 2010 anyone? i might have to offer some $$$ for this one. lol let me know. 0 Quote Link to comment Share on other sites More sharing options...
Grizzlyware Josh Posted August 31, 2010 Share Posted August 31, 2010 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 ! 0 Quote Link to comment Share on other sites More sharing options...
pod Posted August 31, 2010 Author Share Posted August 31, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 31, 2010 Share Posted August 31, 2010 For what its worth, you do not really need a 2-dimensional array for this. You can just do $pidGoals[$pid] = "text" 0 Quote Link to comment Share on other sites More sharing options...
pod Posted August 31, 2010 Author Share Posted August 31, 2010 I am open to suggestions whatever works and is easy for other users to configure. 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 31, 2010 Share Posted August 31, 2010 I'm still not even sure what you're trying to do. 0 Quote Link to comment Share on other sites More sharing options...
pod Posted August 31, 2010 Author Share Posted August 31, 2010 What exactly do you not understand? Do you not understand what the prupose is? Or do you not understand the requirements? 0 Quote Link to comment Share on other sites More sharing options...
laszlof Posted August 31, 2010 Share Posted August 31, 2010 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? 0 Quote Link to comment Share on other sites More sharing options...
pod Posted August 31, 2010 Author Share Posted August 31, 2010 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. 0 Quote Link to comment Share on other sites More sharing options...
Grizzlyware Josh Posted September 15, 2010 Share Posted September 15, 2010 Is this solved now..? 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; } } 0 Quote Link to comment Share on other sites More sharing options...
pod Posted September 15, 2010 Author Share Posted September 15, 2010 yes - we did get things working.... thank you! 0 Quote Link to comment Share on other sites More sharing options...
Grizzlyware Josh Posted September 15, 2010 Share Posted September 15, 2010 Good good 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.