Forum

Thread tagged as: Question, Addons, Members

Members app - track downloads

I have the app working as expected - so I was hesitant to open an issue, but have ran out of ideas. Searching the forum has not helped me solve this.

I need to be able to track which user downloaded a file. I planned on using a google analytics track event, but I am having trouble passing the members name value to the template im using to show the files for download.

This:

<p>Welcome back, <perch:member id="first_name" /></p>

does not work for me on any of the members pages.

I also tried this:

<?php 
    PerchSystem::set_var('lang', 'en');
    perch_content_custom('My region', array(
        'template'=>'template.html'
    ));
?>

<a href="/<perch:content id="lang" />/contact/">Contact Us</a>

But couldn't get that to work. Is this how I should be able to get it to work - using PerchSystem ?

Thanks in advance.

  1. Diagnostics report HEALTH CHECK

Perch is up to date PHP 5.5.20 is up to date MySQL 5.5.42 is up to date Image processing available SUMMARY INFORMATION

Perch: 2.8.4, PHP: 5.5.20, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $, with PDO Server OS: Linux, cgi-fcgi Installed apps: content (2.8.4), assets (2.8.4), categories (2.8.4), perch_blog (4.6), perch_forms (1.7), perch_mailchimp (2.0.1), perch_members (1.2) App runtimes: <?php include(PERCH_PATH.'/core/apps/content/runtime.php'); include(PERCH_PATH.'/core/apps/categories/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_blog/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_forms/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_mailchimp/runtime.php'); include(PERCH_PATH.'/addons/apps/perch_members/runtime.php'); ?> PERCH_LOGINPATH: /cms PERCH_PATH: /public_html/cms PERCH_CORE: /public_html/cms/core PERCH_RESFILEPATH: public_html/cms/resources Image manipulation: GD PHP limits: Max upload 64M, Max POST 64M, Memory: 128M, Total max file upload: 64M Resource folder writeable: Yes HTTP_HOST: DOCUMENT_ROOT: /public_html/ REQUEST_URI: /cms/core/settings/diagnostics/ SCRIPT_NAME: /cms/core/settings/diagnostics/index.php

  1. Download template:
            <perch:repeater id="resources-row-1" label="Resources Row (8)" max="8">
                <perch:before><div class="row"></perch:before>
                    <div class="two cols / resource">
                        <a class="resource__link" href="<perch:content id="file" type="file" label="File" order="5" bucket="secure" />" onClick="_gaq.push(['_trackEvent', 'Resources', 'Download', <perch:member id="first_name" /> ]);">
                            <div class="resource__icon">
                                <img src="<perch:content type="image" id="resource-icon" label="Icon" order="3" />" alt="<perch:content type="text" id="resource-name" />" />
                            </div><!-- /.resource__icon -->
                            <p class="resource__name"><perch:content type="text" id="resource-name" label="Resource Name" required="true" title="true" order="1" /></p><!-- /.resource__name -->
                        </a>
                    </div><!-- /.resource -->
                <perch:after></div><!-- /.row --></perch:after>
            </perch:repeater>
Juan Fernandes

Juan Fernandes 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have a first_name field for your members?

Hi Drew

Yes I do.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't see why that wouldn't work.

Do the examples that come with the app work for you?

Hi Drew

I have uploaded the /members/ folder as it is when downloaded without any changes to here: https://www.mcmwebhosting.com/members/

Log in as drew@test.com and test as the password.

There are 2 welcome backs - the first welcome back is:

<p>Welcome back, <perch:member id="first_name" /></p>

and the second welcome back, the one that works is the php code one:

        <?php
            if (perch_member_logged_in()) {
                echo '<h1>Welcome back, '.perch_member_get('first_name').'!</h1>';
            }else{
                echo '<h1>Hello!</h1>';
                echo '<p>You are not logged in. Please login or <a href="/members/register.php">register</a>.</p>';
            }
        ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok - all I need to know is if those are functioning as you expect.

<p>Welcome back, <perch:member id="first_name" /></p>

The above code does not work in the index.php of the members section or within a template.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. How can I help?

Well that's code that you provide in the example code in members app, so I'm guessing it should work. So I need help trying to work out why it doesn't work for me even when using the example code that ships with the Members app.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you add debug to the page, what does it output?

DEBUG:

Debug Message
SELECT * FROM perch2_pages WHERE pagePath='/resources/index.php' LIMIT 1
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberEmail='fernandes.juan+test@gmail.com' AND memberStatus='active' AND (memberExpires IS NULL OR memberExpires>'2015-04-24 10:33:49') LIMIT 1
Password is ok.
SELECT * FROM perch2_members WHERE memberAuthType='native' AND memberAuthID='1' LIMIT 1
log them in
SELECT t.tag FROM perch2_members_tags t, perch2_members_member_tags mt WHERE t.tagID=mt.tagID AND mt.memberID='1' AND (mt.tagExpires IS NULL OR mt.tagExpires>'2015-04-24 10:33:00')
INSERT INTO perch2_members_sessions(sessionID,sessionExpires,sessionHttpFootprint,memberID,sessionData) VALUES('438f8f5bc0ffb52bbb7108ed999537d78f3c7ce6','2015-04-29 10:33:49','8089bcb6f91c05ad4a65cb05e007856dd65e31eb','1','a:11:{s:10:\"first_name\";s:4:\"Juan\";s:9:\"last_name\";s:9:\"Fernandes\";s:5:\"token\";s:40:\"1266b4bf802fe5be117863d15eb4ff5483087c04\";s:8:\"memberID\";s:1:\"1\";s:14:\"memberAuthType\";s:6:\"native\";s:12:\"memberAuthID\";s:1:\"1\";s:11:\"memberEmail\";s:29:\"fernandes.juan+test@gmail.com\";s:12:\"memberStatus\";s:6:\"active\";s:13:\"memberCreated\";s:19:\"2015-03-27 16:17:29\";s:13:\"memberExpires\";N;s:4:\"tags\";b:0;}')
DELETE FROM perch2_members_sessions WHERE sessionExpires < '2015-04-24 10:33:49'
SELECT * FROM perch2_members_sessions WHERE sessionID='438f8f5bc0ffb52bbb7108ed999537d78f3c7ce6' AND sessionHttpFootprint='8089bcb6f91c05ad4a65cb05e007856dd65e31eb' AND sessionExpires>'2015-04-24 10:33:49' LIMIT 1
User is logged in
Array
(
    [all] => login
)
SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/resources/index.php' OR regionPage='*' ORDER BY regionPage DESC
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/resources/index.php' LIMIT 1
SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-006', '000')
Using template: /templates/navigation/level1.html
Using template: /templates/navigation/level2.html
Using template: /templates/navigation/level2.html
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/resources/index.php' OR pageSortPath='/resources/index.php' LIMIT 1
SELECT * FROM perch2_pages WHERE pageHidden=0 AND pageNew=0 AND pageTreePosition IN ('000-006', '000') ORDER BY pageTreePosition
Using template: /templates/navigation/breadcrumbs.html
Using template: /templates/search/search-form.html
Using template: /templates/members/login/login_form.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

This all looks fine. I'm doing some work with the Members app currently, so I'll see what I can find.

Thanks Drew.

I have a workaround to my original issue of not being able to track user downloads, but if this:

<perch:member id="first_name" />

worked, then it would make it a better solution than what I am using at the moment.

Thanks again