Jump to content

Counting clicks on link/anything


MadLittleMods

Recommended Posts

Alright more on my affiliate page which you guys helped me build last night. Thanks again  :D

 

I want to count the number of times one of the affiliates is clicked. So each one has to have its own impression number.

 

I have my array set up like so: - i see that impression is now 0 and needs to be changed to a variable etc like $aff_blah1_impressions

// affiliates array for affiliates page
$affiliates = array(
  array(
    "title" => "aff_blah1",
    "image" => "http://aff_blah1.net/images/aff_blah1.png",
    "href" => "http://aff_blah1.net/",
    "start_date" => "1/1/2011",
    "impressions" => "0"
  ),

  array(
    "title" => "aff_blah2",
    "image" => "http://aff_blah2.net/images/aff_blah2.png",
    "href" => "http://aff_blah2.net/",
    "start_date" => "1/1/2011",
    "impressions" => "0"
  ),

array(
    "title" => "aff_blah3",
    "image" => "http://aff_blah3.net/images/aff_blah3.png",
    "href" => "http://aff_blah3.net/",
    "start_date" => "1/1/2011",
    "impressions" => "0"
  ),
);
// affiliates array end

 

I have seen some examples but they all use a text file.

 

Is there any way to have it stored in the database?

 

I was thinking it would somehow be in the link with like a onClick (which is java) that would run a php function. What i am trying to figure out is the best way to store it and have only one function for impressions made on each affiliate.

 

Any keyword search terms or links would be very helpful!

 

Can also contact through AIM: MadLittleMods@gmail.com

Link to comment
Share on other sites

Store the actual link in a database.  The clickable URL should then route to a page that can pass the "ID" of the URL clicked, reference it in the database, increment the count, then launch the URL.  Just a thought off the top of my head how I would go about doing it.

Link to comment
Share on other sites

revraz I want impressions to be a variable $aff_blah2_impressions_count but do not know how to put it in. When put in with no quotes or single quotes it gives me a bunch of errors.

 

How should i put it into the array?

 

"title" => "aff_blah2",
    "image" => "http://aff_blah2.net/images/aff_blah2.png",
    "href" => "http://aff_blah2.net/",
    "start_date" => "1/1/2011",
    "impressions" => "0"

 

 

Link to comment
Share on other sites

Alright that is where everything is called.. (attached)

 

 

Array is in subs.php (smf, if you are familiar)

 

Whole array:

/// affiliates array for affiliates page
$affiliates = array(
  array(
    "title" => "aff_blah1",
    "image" => "http://aff_blah1.net/images/aff_blah1.png",
    "href" => "http://aff_blah1.net/",
    "start_date" => "1/1/2011",
    "impressions" => "0"
  ),

  array(
    "title" => "aff_blah2",
    "image" => "http://aff_blah2.net/images/aff_blah2.png",
    "href" => "http://aff_blah2.net/",
    "start_date" => "1/1/2011",
    "impressions" => "0"
  ),

array(
    "title" => "aff_blah3",
    "image" => "http://aff_blah3.net/images/aff_blah3.png",
    "href" => "http://aff_blah3.net/",
    "start_date" => "1/1/2011",
    "impressions" => "0"
  ),
);
// affiliates array end

 

[attachment deleted by admin]

Link to comment
Share on other sites

Wait the attachments does  what i am wanting to do. Let me look at my smf code for this and see if i can decipher it.

 

Every time you click the attachment link it goes up 1.

 

Well here is my lead on smf - have to go *sigh* (will look closer tommorrow but here it is)


	// Assuming there are attachments...
	if (!empty($message['attachment']))
	{
		echo '
						<div id="msg_', $message['id'], '_footer" class="attachments smalltext">
							<div style="overflow: ', $context['browser']['is_firefox'] ? 'visible' : 'auto', ';">';

		$last_approved_state = 1;
		foreach ($message['attachment'] as $attachment)
		{
			// Show a special box for unapproved attachments...
			if ($attachment['is_approved'] != $last_approved_state)
			{
				$last_approved_state = 0;
				echo '
								<fieldset>
									<legend>', $txt['attach_awaiting_approve'];

				if ($context['can_approve'])
					echo ' [<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';

				echo '</legend>';
			}

			if ($attachment['is_image'])
			{
				if ($attachment['thumbnail']['has_thumb'])
					echo '
									<a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '" /></a><br />';
				else
					echo '
									<img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '"/><br />';
			}
			echo '
									<a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.gif" align="middle" alt="*" /> ' . $attachment['name'] . '</a> ';

			if (!$attachment['is_approved'] && $context['can_approve'])
				echo '
									[<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>] | [<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
			echo '
									(', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . ' - ' . $txt['attach_viewed'] : ' - ' . $txt['attach_downloaded']) . ' ' . $attachment['downloads'] . ' ' . $txt['attach_times'] . '.)<br />';
		}

		// If we had unapproved attachments clean up.
		if ($last_approved_state == 0)
			echo '
								</fieldset>';

		echo '
							</div>
						</div>';
	}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.